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

Git, GitHub and Open Source

Lorna Mitchell
November 20, 2013

Git, GitHub and Open Source

Lorna Mitchell

November 20, 2013

More Decks by Lorna Mitchell

Other Decks in Technology


  1. Git, GitHub and Open Source Lorna Mitchell, NW DrupalCamp 2013

  2. GitHub "We make it easier to collaborate with others and

    share your projects with the universe" • GitHub is hosted source control, based on git • Used for many open source projects, also good for your own projects • Competing alternatives exist
  3. How to Get Code from GitHub

  4. Find and Fork First, find the project and fork it

  5. Why Fork? • To have your own copy • To

    allow you to share changes without having write access • It is possible to clone a read-only repository
  6. Clone the Repo Get the URL you need (https recommended)

  7. Clone the Repo Clone it

  8. Examining Changes with Git

  9. Git Log This goes to a pager; press 'q' to

  10. Git Log My favourite switches: git log --oneline --graph --decorate

  11. Stay in Sync

  12. Git Remotes Your local repo has remotes • origin is

    created by default and points to where you cloned from • upstream is usually the main project repo • Add as many remotes as there are collaboration points To view remotes: git remote -v
  13. Remote and Local Repos

  14. Get Upstream Changes git pull upstream master

  15. Get Upstream Changes

  16. Update Your Fork Push changes from your local fork to

    your GitHub origin: git push This defaults to origin but you can also specify which branch to push and to where: git push upstream develop
  17. Update Your Fork

  18. Git and Branching Branching is quick, easy and efficient. More

    importantly, so is merging! Your repo will switch itself to a different branch when asked
  19. Git Branching Strategies Each project will have its own branching

    strategy. You may need to: • branch per feature • branch per ticket (with appropriately-named branches) • branch per version
  20. Make a Branch New branch called experiment: git checkout -b

    experiment Push the contents of that branch to your GitHub origin: git push origin experiment Change to an existing branch: git checkout otherCoolFeature
  21. Make and Share Changes

  22. Making Changes in Git Changes can be in one of

    three states
  23. Git Status Shows various sets of changes • Changes staged

    for commit • Modified files • Untracked files • (Unmodified tracked files aren't shown)
  24. Make Changes When a file has been changed, run git

  25. Git Diff See changes in the working area: git diff

    See changes staged for commit: git diff --staged
  26. Prepare Changes Use git add README.md to add the file

  27. Some Notes on Committing • One feature, many atomic commits,

    one branch • Meaningful commit messages • Layout/coding standard fixes should be separate • Git encourages careful preparation of commits
  28. Commit and Share Complete the changeset by committing git commit

    -m "Excellent message here"
  29. Commit and Share

  30. Commit and Share

  31. Your Changes on GitHub Since we pushed to GitHub, we

    can see the changes there:
  32. Pull Requests Literally request someone does a pull from your

    repo! They provide: • an easy way to see offered changes • a great interface for reviewing changes • tools for discussion of changes
  33. Open a Pull Request Go to the new branch you

  34. Open a Pull Request Check the diff and add a

  35. Open a Pull Request

  36. Open a Pull Request You'll get an email when it

    is updated
  37. Contributing to Open Source

  38. When to Contribute When you can improve a project Even

    a teeny tiny bit
  39. Why to Contribute To help To improve your own skills

    As an excellent hobby
  40. How to Contribute Projects will publish some information for you

    • Contributor guidelines • Contact mechanisms • Issue lists http://joind.in/about
  41. Questions?

  42. Thanks Feedback please! Lorna Mitchell, consultant, author, developer and trainer,

    available for interesting projects • http://github.com/lornajane • @lornajane • http://lornajane.net