Successfully reported this slideshow.

Git102

1,165 views

Published on

Intro to Git slide deck.

Covers Forking, pushing and pulling to Github, Pull requests

Published in: Technology
  • Be the first to comment

Git102

  1. 1. Our project on GitHub <ul><li>http: //github . com/jasonnoble/event_scheduler </li></ul><ul><ul><li>Click Fork </li></ul></ul>
  2. 2. Fork Command <ul><li>Fork is a GitHub thing, it’s not a Git command </li></ul><ul><li>Clicking fork basically copies a repo on Github into your Github account </li></ul><ul><li>This provides a public repo that you have access to push your changes to </li></ul>
  3. 3. Public/Private Repo Setup Jasonnoble/ event_scheduler (on GitHub) your-user-name/ event_scheduler (on GitHub) hosh/ event_scheduler (on GitHub) Fork Other Public Repos event_scheduler Local Repo Clone Your Public Repo Project Public Repo stonean/ event_scheduler (on GitHub) Public Repo Private Repo
  4. 4. Your project on GitHub <ul><li>http://github.com/your-user-name/event_scheduler </li></ul>
  5. 5. Clone your Repo <ul><li>git clone [email_address] .com: your-user-name/event_scheduler . git </li></ul><ul><li>cd event_scheduler </li></ul><ul><li>git pull </li></ul><ul><ul><li>Should say “Already up-to-date” </li></ul></ul><ul><li>This clone command adds a remote repo “origin” (explained in detail later) </li></ul><ul><li>A clone is the entire history of the Git Repo </li></ul><ul><ul><li>History of all changes </li></ul></ul><ul><ul><li>Log messages </li></ul></ul>
  6. 6. Modify a file <ul><li>vi (or your favorite editor) AUTHORS </li></ul><ul><li>Add your name </li></ul><ul><li>Save the file </li></ul>
  7. 7. Git diff <ul><li>git diff </li></ul><ul><li>Shows what has changed since your last commit </li></ul>
  8. 8. Git Status <ul><li>Shows the status of your git repo / working directory </li></ul><ul><li>git status </li></ul>
  9. 9. Git add <ul><li>Stages files to be committed </li></ul><ul><li>git add AUTHORS </li></ul>
  10. 10. Git Commit <ul><li>Commit your changes </li></ul><ul><li>git commit -v </li></ul><ul><li>Options: </li></ul><ul><ul><li>a Add all known files </li></ul></ul><ul><ul><li>v Verbose (show diff in editor) </li></ul></ul><ul><ul><li>m Command line commit message </li></ul></ul>
  11. 11. Git commit (cont.)
  12. 12. Pushing/Pulling to Origin Jasonnoble/ event_scheduler your-user-name/ event_scheduler hosh/ event_scheduler Other forks event_scheduler Local Repo git pull origin git push Allowed by default Requires permission Remotes: origin upstream hosh
  13. 13. Git Push <ul><li>Push your changes to GitHub </li></ul><ul><li>git push origin master </li></ul>
  14. 14. Pushing/Pulling to upstream Jasonnoble/event_scheduler your-user-name/event_scheduler hosh/event_scheduler Other forks event_scheduler Local Repo upstream origin hosh Allowed by default Requires permission git push upstream master git pull upstream master Remotes: origin upstream hosh
  15. 15. Add upstream <ul><li>In order to pull updates from other sources, you need to add a remote server </li></ul>
  16. 16. Add upstream (cont.) <ul><li>git remote add upstream git://github.com/jasonnoble/event_scheduler.git </li></ul><ul><ul><li>“ upstream” is whatever you want to call it </li></ul></ul><ul><ul><li>“ upstream” for the repo you forked from is a GitHub convention </li></ul></ul><ul><li>git fetch upstream </li></ul><ul><ul><li>Fetches references from upstream </li></ul></ul>
  17. 17. Create local branch <ul><li>git checkout --track -b upstream-master upstream/master </li></ul><ul><ul><li>upstream-master is what you will call it locally </li></ul></ul>
  18. 18. Pull remote changes <ul><li>git checkout upstream-master </li></ul><ul><li>git pull </li></ul><ul><ul><li>pull updates from the remote </li></ul></ul>
  19. 19. Show diffs between branches <ul><li>git show-branch </li></ul>
  20. 20. Merge branches <ul><li>git checkout master </li></ul><ul><li>git merge upstream-master </li></ul><ul><ul><li>Merges any changes committed to upstream-master into the master branch </li></ul></ul><ul><li>After merge, do a git push to push that merge to your public repo on GitHub </li></ul>
  21. 21. Pulling from Upstream Lab <ul><li>I will commit a change to my public repo (upstream) </li></ul><ul><li>You add upstream as a remote repo </li></ul><ul><li>Pull from the repo to get the changes </li></ul>
  22. 22. Pushing/Pulling to other remote repos Jasonnoble/ event_scheduler your-user-name/ event_scheduler hosh/ event_scheduler Other forks event_scheduler Local Repo upstream origin hosh git push hosh master git pull hosh master Allowed by default Requires permission Remotes: origin upstream hosh
  23. 23. Practice makes perfect <ul><li>Find a pair to work with </li></ul><ul><li>Add their remote repo </li></ul><ul><ul><li>git remote add _____ git://github….. </li></ul></ul><ul><li>Fetch refs </li></ul><ul><ul><li>git fetch _______ </li></ul></ul><ul><li>Create Branch </li></ul><ul><ul><li>git checkout --track -b ______ _____/master </li></ul></ul>
  24. 24. Practice makes perfect (Cont.) <ul><li>Make some changes, push them to origin/master and have your pair pull those changes </li></ul><ul><li>Switch roles and you pull changes they’ve pushed </li></ul><ul><li>Play with the “pull request” feature of GitHub </li></ul>

×