0
gitr’ done!<br />A brief introduction to<br />distributed version control with git<br />Oscar Nierstrasz — University of B...
Why git?<br />
Bob<br />
Bob<br />Carol<br />
Bob<br />Carol<br />Alice<br />Ted<br />
Bob<br />Carol<br />Alice<br />Ted<br />A recipe for disaster!<br />
The git object model<br />
A “blob” is content under version control (a file)<br />blob<br />
You can have trees of blobs<br />(directories of files)<br />tree<br />blob<br />tree<br />blob<br />blob<br />
A “commit” is a tree of blobs<br />(a set of changes)<br />commit<br />tree<br />blob<br />tree<br />blob<br />blob<br />
Most commits modify (or merge) earlier commits<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<b...
You can “tag” an interesting commit<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<br ...
A graph of commits may belong to a branch<br />branch<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />...
HEAD<br />“HEAD “is the current branch<br />branch<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />blo...
HEAD<br />branch<br />commit<br />commit<br />Let’s focus on commits and branches<br />
Basic git<br />
Create a git repo<br />HEAD<br />mkdir repo<br />cd repo<br />git init<br />master<br />C0<br />
Tell git to “stage” changes<br />HEAD<br />git add …<br />master<br />C0<br />
HEAD<br />Commit your changes<br />master<br />C1<br />git commit …<br />C0<br />
Collaborating<br />
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />master<br />C1<br />C0<br />
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git clone …<br />master<br />master<br />master<br />...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />master<br />master<br />master<br />C1<br />C2<br />C...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git pull<br />master<br />master<br />master<br />C1<...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git push<br />master<br />master<br />master<br />C2<...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git fetch<br />master<br />master<br />master<br />C2...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git merge<br />master<br />master<br />master<br />C2...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git push<br />master<br />master<br />master<br />C4<...
John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git pull<br />master<br />master<br />master<br />C4<...
Branching and merging<br />
“origin” refers to the remote repo<br />HEAD<br />master<br />origin/master<br />C1<br />C0<br />
HEAD<br />master<br />…<br />git commit …<br />origin/master<br />C2<br />C1<br />C0<br />
git branch tryout<br />HEAD<br />tryout<br />master<br />origin/master<br />C2<br />C1<br />C0<br />
git checkout tryout<br />HEAD<br />tryout<br />master<br />origin/master<br />C2<br />C1<br />NB:git checkout –b … = branc...
HEAD<br />tryout<br />master<br />git commit …<br />C3<br />origin/master<br />C2<br />C1<br />C0<br />
HEAD<br />tryout<br />master<br />C3<br />C5<br />origin/master<br />C2<br />C1<br />origin/idea<br />C4<br />C6<br />C0<b...
git merge origin/master origin/idea<br />HEAD<br />tryout<br />C7<br />master<br />C3<br />origin/master<br />C5<br />C2<b...
git checkout master<br />tryout<br />HEAD<br />C7<br />master<br />C3<br />origin/master<br />C5<br />C2<br />C1<br />C4<b...
git merge<br />HEAD<br />tryout<br />master<br />C7<br />C8<br />C3<br />origin/master<br />C5<br />C2<br />C1<br />C4<br ...
git push<br />HEAD<br />tryout<br />master<br />C7<br />origin/master<br />C8<br />C3<br />C5<br />C2<br />C1<br />C4<br /...
More to git<br />
More to git …<br />Merging and mergetool<br />Squashing commits when merging<br />Resolving conflicts<br />User authentica...
Resources<br />http://book.git-scm.com/index.html<br />http://git-scm.com/<br />https://github.com/<br />http://www.slides...
License<br />Attribution-ShareAlike 2.5<br />You are free:<br /><ul><li>to copy, distribute, display, and perform the work
Upcoming SlideShare
Loading in...5
×

Git primer

3,715

Published on

A brief introduction to distributed version control with git.
Shamelessly adapted from Scott Chacon's excellent "Getting Git" talk: http://www.slideshare.net/chacon/getting-git

Published in: Education, Technology, Business
1 Comment
4 Likes
Statistics
Notes
No Downloads
Views
Total Views
3,715
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
89
Comments
1
Likes
4
Embeds 0
No embeds

No notes for slide
  • Inspired by:Getting Git by Scott Chacon — http://www.slideshare.net/chacon/getting-gitThe git Community Book — http://book.git-scm.com/index.htmlPicture: Larry the Cable Guy
  • Transcript of "Git primer"

    1. 1. gitr’ done!<br />A brief introduction to<br />distributed version control with git<br />Oscar Nierstrasz — University of Bern — scg.unibe.ch<br />
    2. 2. Why git?<br />
    3. 3. Bob<br />
    4. 4. Bob<br />Carol<br />
    5. 5. Bob<br />Carol<br />Alice<br />Ted<br />
    6. 6. Bob<br />Carol<br />Alice<br />Ted<br />A recipe for disaster!<br />
    7. 7. The git object model<br />
    8. 8. A “blob” is content under version control (a file)<br />blob<br />
    9. 9. You can have trees of blobs<br />(directories of files)<br />tree<br />blob<br />tree<br />blob<br />blob<br />
    10. 10. A “commit” is a tree of blobs<br />(a set of changes)<br />commit<br />tree<br />blob<br />tree<br />blob<br />blob<br />
    11. 11. Most commits modify (or merge) earlier commits<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<br />blob<br />blob<br />
    12. 12. You can “tag” an interesting commit<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<br />blob<br />blob<br />
    13. 13. A graph of commits may belong to a branch<br />branch<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<br />blob<br />blob<br />
    14. 14. HEAD<br />“HEAD “is the current branch<br />branch<br />tag<br />commit<br />commit<br />tree<br />tree<br />blob<br />blob<br />tree<br />blob<br />blob<br />
    15. 15. HEAD<br />branch<br />commit<br />commit<br />Let’s focus on commits and branches<br />
    16. 16. Basic git<br />
    17. 17. Create a git repo<br />HEAD<br />mkdir repo<br />cd repo<br />git init<br />master<br />C0<br />
    18. 18. Tell git to “stage” changes<br />HEAD<br />git add …<br />master<br />C0<br />
    19. 19. HEAD<br />Commit your changes<br />master<br />C1<br />git commit …<br />C0<br />
    20. 20. Collaborating<br />
    21. 21. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />master<br />C1<br />C0<br />
    22. 22. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git clone …<br />master<br />master<br />master<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />git clone …<br />
    23. 23. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />master<br />master<br />master<br />C1<br />C2<br />C3<br />C0<br />C1<br />C1<br />C0<br />C0<br />git add …<br />git commit …<br />git add …<br />git commit …<br />
    24. 24. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git pull<br />master<br />master<br />master<br />C1<br />C2<br />C3<br />C0<br />C1<br />C1<br />C0<br />C0<br />(nothing new to pull)<br />
    25. 25. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git push<br />master<br />master<br />master<br />C2<br />C2<br />C3<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />
    26. 26. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git fetch<br />master<br />master<br />master<br />C2<br />C2<br />C3<br />C2<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />
    27. 27. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git merge<br />master<br />master<br />master<br />C2<br />C4<br />C2<br />C3<br />C2<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />NB:git pull = fetch + merge<br />
    28. 28. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git push<br />master<br />master<br />master<br />C4<br />C4<br />C2<br />C3<br />C2<br />C3<br />C2<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />
    29. 29. John<br />Jane<br />Public repo<br />Local repo<br />Local repo<br />git pull<br />master<br />master<br />master<br />C4<br />C4<br />C4<br />C3<br />C3<br />C2<br />C2<br />C3<br />C2<br />C1<br />C1<br />C1<br />C0<br />C0<br />C0<br />
    30. 30. Branching and merging<br />
    31. 31. “origin” refers to the remote repo<br />HEAD<br />master<br />origin/master<br />C1<br />C0<br />
    32. 32. HEAD<br />master<br />…<br />git commit …<br />origin/master<br />C2<br />C1<br />C0<br />
    33. 33. git branch tryout<br />HEAD<br />tryout<br />master<br />origin/master<br />C2<br />C1<br />C0<br />
    34. 34. git checkout tryout<br />HEAD<br />tryout<br />master<br />origin/master<br />C2<br />C1<br />NB:git checkout –b … = branch + checkout<br />C0<br />
    35. 35. HEAD<br />tryout<br />master<br />git commit …<br />C3<br />origin/master<br />C2<br />C1<br />C0<br />
    36. 36. HEAD<br />tryout<br />master<br />C3<br />C5<br />origin/master<br />C2<br />C1<br />origin/idea<br />C4<br />C6<br />C0<br />git fetch origin<br />
    37. 37. git merge origin/master origin/idea<br />HEAD<br />tryout<br />C7<br />master<br />C3<br />origin/master<br />C5<br />C2<br />C1<br />C4<br />C6<br />C0<br />origin/idea<br />
    38. 38. git checkout master<br />tryout<br />HEAD<br />C7<br />master<br />C3<br />origin/master<br />C5<br />C2<br />C1<br />C4<br />C6<br />C0<br />origin/idea<br />
    39. 39. git merge<br />HEAD<br />tryout<br />master<br />C7<br />C8<br />C3<br />origin/master<br />C5<br />C2<br />C1<br />C4<br />C6<br />C0<br />origin/idea<br />
    40. 40. git push<br />HEAD<br />tryout<br />master<br />C7<br />origin/master<br />C8<br />C3<br />C5<br />C2<br />C1<br />C4<br />C6<br />C0<br />origin/idea<br />
    41. 41. More to git<br />
    42. 42. More to git …<br />Merging and mergetool<br />Squashing commits when merging<br />Resolving conflicts<br />User authentication with ssh<br />gitx and other graphical tools<br />git configure — remembering your name<br />git remote — multiple remote repos<br />github — an open source public repo<br />…<br />
    43. 43. Resources<br />http://book.git-scm.com/index.html<br />http://git-scm.com/<br />https://github.com/<br />http://www.slideshare.net/chacon/getting-git<br />http://oreilly.com/<br />
    44. 44. License<br />Attribution-ShareAlike 2.5<br />You are free:<br /><ul><li>to copy, distribute, display, and perform the work
    45. 45. to make derivative works
    46. 46. to make commercial use of the work</li></ul>Under the following conditions:<br />Attribution. You must attribute the work in the manner specified by the author or licensor.<br />Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.<br /><ul><li>For any reuse or distribution, you must make clear to others the license terms of this work.
    47. 47. Any of these conditions can be waived if you get permission from the copyright holder.</li></ul>Your fair use and other rights are in no way affected by the above.<br />http://creativecommons.org/licenses/by-sa/2.5/<br />
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×