Quick Introduction to git

7,657
-1

Published on

Quick Introduction to git

  1. 1. Distributed version control with git— a brief introductionJoel KrebsSlides by Oscar Nierstrasz
  2. 2. Why git?
  3. 3. Bob
  4. 4. Bob Carol
  5. 5. Bob CarolAlice Ted
  6. 6. Bob CarolAlice Ted A recipe for disaster!
  7. 7. What is git?
  8. 8. > Distributed revision control system> Originally developed by Linus Torvalds for the development of the Linux Kernel in 2005> Focus on speed and efficiency> Quite a unique design and therefore sometimes a bit scary and difficult to understand
  9. 9. The git object model
  10. 10. A “blob” is content under version control (a file) blob
  11. 11. You can have trees of blobs (directories of files) tree blob tree blob blob
  12. 12. A “commit” is a tree of blobs (a set of changes) commit tree blob tree blob blob
  13. 13. Most commits modify (or merge) earlier commits commit commit tree tree blobblob treeblob blob
  14. 14. You can “tag” aninteresting commit tag commit commit tree tree blob blob tree blob blob
  15. 15. A graph of commitsmay belong to a branch branch tag commit commit tree tree blob blob tree blob blob
  16. 16. HEAD “HEAD “is the current branch branch tag commit commit tree tree blobblob treeblob blob
  17. 17. HEAD branch commit commitLet’s focus on commits and branches
  18. 18. Basic git
  19. 19. Create a git repo HEAD master C0
  20. 20. Tell git to “stage” changesHEADmaster C0
  21. 21. HEADmaster Commit your changes C1 C0
  22. 22. Collaborating
  23. 23. John JaneLocal repo Public repo Local repo master C1 C0
  24. 24. John JaneLocal repo Public repo Local repo master master master C1 C1 C1 C0 C0 C0
  25. 25. John JaneLocal repo Public repo Local repo master master master C2 C1 C3 C1 C0 C1 C0 C0
  26. 26. John Jane Local repo Public repo Local repo master master master C2 C1 C3 C1 C0 C1 C0 C0(nothing new to pull)
  27. 27. John JaneLocal repo Public repo Local repo master master master C2 C2 C3 C1 C1 C1 C0 C0 C0
  28. 28. John JaneLocal repo Public repo Local repo master master master C2 C2 C3 C2 C1 C1 C1 C0 C0 C0
  29. 29. John JaneLocal repo Public repo Local repo master master master C2 C2 C4 C1 C1 C3 C2 C0 C0 C1 C0 NB: git pull = fetch + merge
  30. 30. John JaneLocal repo Public repo Local repo master master master C2 C4 C4 C1 C3 C2 C3 C2 C0 C1 C1 C0 C0
  31. 31. John JaneLocal repo Public repo Local repo master master master C4 C4 C4 C3 C2 C3 C2 C3 C2 C1 C1 C1 C0 C0 C0
  32. 32. Branchingand merging
  33. 33. “origin” refers to the remote repo HEAD masterorigin/master C1 C0
  34. 34. HEAD masterorigin/master C2 C1 C0
  35. 35. HEAD tryout masterorigin/master C2 C1 C0
  36. 36. HEAD tryout masterorigin/master C2 C1 NB: git checkout –b … = branch + checkout C0
  37. 37. HEAD tryout master C3origin/master C2 C1 C0
  38. 38. HEAD tryoutmaster C3 C5 C2 origin/master C1 C4 C6 C0 origin/idea
  39. 39. HEAD tryout C7master C3 C5 C2 origin/master C1 C4 C6 C0 origin/idea
  40. 40. tryoutHEAD C7master C3 C5 C2 origin/master C1 C4 C6 C0 origin/idea
  41. 41. HEAD tryoutmaster C7 C8 C3 C5 C2 origin/master C1 C4 C6 C0 origin/idea
  42. 42. HEAD tryout master C7origin/master C8 C3 C5 C2 C1 C4 C6 C0 origin/idea
  43. 43. Overview git workflow Remote repository fetch push Local repository pull commit checkout Index (cache) HEAD add Working directory
  44. 44. Getting started
  45. 45. First steps> Follow instructions on P2 Blog for installation> Send your ssh public key to joel.krebs@students.unibe.ch> Create meaningful commits with according messages> Hints that make your life easier: —Create a .gitignore file —Always pull before you push —Don’t panic when merge conflicts occur
  46. 46. More to git
  47. 47. More to git …> Merging and mergetool> Squashing commits when merging> Resolving conflicts> User authentication with ssh> gitx and other graphical tools> git configure — remembering your name> git remote — multiple remote repos> github — an open source public repo> …
  48. 48. Resources http://git-scm.com/ http://book.git-scm.com/index.html http://gitready.com/ https://github.com/http://www.slideshare.net/chacon/getting-git http://oreilly.com/
  49. 49. http://creativecommons.org/licenses/by-sa/3.0/

×