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. A Noob’s Intro to using Git
    for Open Source
    SUBHRAJYOTI SEN

    View Slide

  2. Who Am I?
    Subhrajyoti Sen
    • Open Source Enthusiast
    • Mozillian
    • Android Developer
    • Net Neutrality and Privacy advocate

    View Slide

  3. What is Open Source
    The term "open source" refers to
    something people can modify and share
    because its design is publicly accessible.

    View Slide

  4. Some Famous Open Source Projects

    View Slide

  5. Why Contribute to Open Source
    • Amazing Learning Opportunities
    • Amazing Communities
    • Big Plus on CV
    • You can go places. Literally
    • You get direct credits

    View Slide

  6. 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

    View Slide

  7. 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

    View Slide

  8. Writing Proper Commit Messages

    View Slide

  9. 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 "

    View Slide

  10. 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

    View Slide

  11. Cherry Picking – How?
    Cherry-pick is 2-step process
    1. Fetching
    • git fetch remote branch
    2. Cherry Picking
    • git cherry-pick

    View Slide

  12. Hard Reset
    • Rewrite commit history
    • Useful for “remove password” situation
    • Needs a force push
    git reset --hard

    View Slide

  13. 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

    View Slide

  14. 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”

    View Slide

  15. Pull Request
    1. Fork
    2. Clone
    3. Commit
    4. Push
    5. Make Pull Request
    6. Repeat

    View Slide

  16. 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.

    View Slide

  17. 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

    View Slide

  18. 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

    View Slide

  19. THANK YOU
    @iamsubhrajyoti
    @SubhrajyotiSen

    View Slide