Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Noob's Guide to Git for Open Source

A Noob's Guide to Git for Open Source

Subhrajyoti Sen

October 07, 2017
Tweet

More Decks by Subhrajyoti Sen

Other Decks in Programming

Transcript

  1. Who Am I? Subhrajyoti Sen • Open Source Enthusiast •

    Mozillian • Android Developer • Net Neutrality and Privacy advocate
  2. What is Open Source The term "open source" refers to

    something people can modify and share because its design is publicly accessible.
  3. Why Contribute to Open Source • Amazing Learning Opportunities •

    Amazing Communities • Big Plus on CV • You can go places. Literally • You get direct credits
  4. Contribution Guidelines source: youtube-dl For the repository owner, contribution guidelines

    are a way to communicate how people should contribute. For contributors, the guidelines help them verify that they're submitting well-formed pull requests and opening useful issues. - GitHub
  5. Writing Proper Commit Messages • No swear words • Get

    straight to the point • Proper references • Write messages that you can understand a year down the line • Commit message length can vary from two sentences to multiple paragraphs
  6. Maintaining Authorship • The person making the changes in the

    commit is the author • It’s always OK to use someone's commit in your project but with authorship • It’s NOT OK to change authorship of a commit git commit --amend --author="Name <email>"
  7. Cherry Picking • Apply an existing commit to your project

    • The part modified by the commit should have a similar structure to the existing project • Automatically maintains authorship • Used extensively in Linux kernel and AOSP development
  8. Cherry Picking – How? Cherry-pick is 2-step process 1. Fetching

    • git fetch remote branch 2. Cherry Picking • git cherry-pick <commit-hash>
  9. Hard Reset • Rewrite commit history • Useful for “remove

    password” situation • Needs a force push git reset --hard <commit-hash>
  10. Force pushing • With great power comes great responsibility •

    When in doubt, use it with supervision • Never do it in production code git push –f remote branch
  11. Squashing • Combine multiple commits into a single commit •

    Better readability of commit history • Always suggested while making a PR for a single issue git reset --soft HEAD~X git commit –m “New commit message”
  12. Pull Request 1. Fork 2. Clone 3. Commit 4. Push

    5. Make Pull Request 6. Repeat
  13. Merge Conflicts Sometimes there are competing changes that Git needs

    your help with to decide which changes to incorporate in the final merge. Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file.
  14. Rebasing Useful when to update a fork 1. git checkout

    target-branch 2. git pull upstream target-branch 3. git checkout victim-branch 4. git rebase target-branch 5. git push –f origin victim-branch
  15. How to Find your First Bug Some amazing resources to

    find your first bug to solve • http://up-for-grabs.net • http://issuehub.io • GitHub Search: easy, low hanging fruit, beginner • @first_tmrs_only