Git Going With DVCS v1.3

1,567 views

Published on

An updated introduction to the Git Distributed Version Control System. Be prepared to have everything you know about centralized VCS systems turned upside down, but all for the benefit of easy of use, better team-mate interactions, and more robust (guaranteed) repository integrity and uptime.

Published in: Education, Technology
1 Comment
1 Like
Statistics
Notes
  • Wow. you did amazing presentation. so helpful. really thanks..
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
1,567
On SlideShare
0
From Embeds
0
Number of Embeds
30
Actions
Shares
0
Downloads
48
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

Git Going With DVCS v1.3

  1. 1. Git going DVCS with n bending mental spoo minutes of 90 ode control ia source c v by Matthew McCullough of Ambient Ideas, LLC
  2. 2. “ Git -noun sant or unplea Slang. an British ” per son emptible cont ionar y rd English Dict -Oxfo
  3. 3. astard, and otistical b “ I'm an eg projects all my I name yself. Fi rst Linux, after m git. ” now us Torvalds -Lin
  4. 4. RCS Folders
  5. 5. Clear Source Case Safe CVS PVCS RCS Folders
  6. 6. Subversion BitKeeper Perforce Clear Source Case Safe CVS PVCS RCS Folders
  7. 7. darcs Mercurial Bazaar Subversion BitKeeper Perforce Clear Source Case Safe CVS PVCS RCS Folders
  8. 8. t Source Code Control Gi
  9. 9. Gi Source Code Control t
  10. 10. CultureChange
  11. 11. =Don’t Centralized VCS
  12. 12. Innovate
  13. 13. Experiment
  14. 14. Safely Be Wrong
  15. 15. Drive-by Assist
  16. 16. Crowd Source
  17. 17. Global Git Settings git config --global user.name quot;Hal Smithquot;
  18. 18. Global Git Settings git config --global user.name quot;Hal Smithquot; git config --global user.email quot;hal@bnl.comquot;
  19. 19. Global Git Settings git config --global user.name quot;Hal Smithquot; git config --global user.email quot;hal@bnl.comquot; ues val ent urr tc tpu Ou git config --list
  20. 20. Creating a Repo mkdir myproj.git
  21. 21. Creating a Repo mkdir myproj.git cd myproj.git
  22. 22. Creating a Repo mkdir myproj.git cd myproj.git lks! t fo ’s i hat git init T
  23. 23. Who’s Got Git?
  24. 24. Hashes and Integrity
  25. 25. SHA-1 Hash Index vs. Hash ‣ Centralized VCS uses DB auto-increment index. ‣ Git uses SHA-1 hash. ‣ Hash for the sake of integrity. Hashable Objects ‣ Blob ‣ Tree ‣ Commit ‣ Tag
  26. 26. SHA-1 Hash Index vs. Hash ‣ Centralized VCS uses DB auto-increment index. ‣ Git uses SHA-1 hash. ‣ Hash for the sake of integrity. Hashable Objects ght hou It ere ‣ Blob es w ash h ‣ Tree for rds? ‣ Commit swo pas ‣ Tag
  27. 27. http://book.git-scm.com/1_the_git_object_model.html
  28. 28. http://book.git-scm.com/1_the_git_object_model.html
  29. 29. http://book.git-scm.com/1_the_git_object_model.html
  30. 30. http://book.git-scm.com/1_the_git_object_model.html
  31. 31. alized entr C Alice Bob
  32. 32. alized entr C Alice Bob 1 = okay.htm
  33. 33. alized entr C Alice Bob 1 = okay.htm 2 = fine.htm
  34. 34. alized entr C Alice Bob 1 = okay.htm 2 = fine.htm Sync
  35. 35. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync
  36. 36. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync 3 = good.htm
  37. 37. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync 3 = good.htm 3 = great.htm
  38. 38. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync 3 = good.htm Sync 3 = great.htm
  39. 39. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync 4 = good.htm 3 = good.htm Sync 3 = great.htm 4 = great.htm
  40. 40. alized entr C Alice Bob 1 = okay.htm 1 = okay.htm 2 = fine.htm 2 = fine.htm Sync ERROR 4 = good.htm 3 = good.htm ERROR Sync 3 = great.htm 4 = great.htm
  41. 41. Distributed Alice Bob
  42. 42. Distributed Alice Bob a233b76 = okay.htm
  43. 43. Distributed Alice Bob a233b76 = okay.htm d234ab1 = fine.htm
  44. 44. Distributed Alice Bob a233b76 = okay.htm d234ab1 = fine.htm Sync
  45. 45. Distributed Alice Bob a233b76 = okay.htm a233b76 = okay.htm d234ab1 = fine.htm d234ab1 = fine.htm Sync
  46. 46. Distributed Alice Bob a233b76 = okay.htm a233b76 = okay.htm d234ab1 = fine.htm d234ab1 = fine.htm Sync f90b12c = good.htm
  47. 47. Distributed Alice Bob a233b76 = okay.htm a233b76 = okay.htm d234ab1 = fine.htm d234ab1 = fine.htm Sync f90b12c = good.htm ae42ba0 = great.htm
  48. 48. Distributed Alice Bob a233b76 = okay.htm a233b76 = okay.htm d234ab1 = fine.htm d234ab1 = fine.htm Sync f90b12c = good.htm Sync ae42ba0 = great.htm
  49. 49. Distributed Alice Bob a233b76 = okay.htm a233b76 = okay.htm d234ab1 = fine.htm d234ab1 = fine.htm Sync f90b12c = good.htm f90b12c = good.htm Sync ae42ba0 = great.htm ae42ba0 = great.htm
  50. 50. Hash Benefits Integrity ‣ Identifies damaged repos. ‣ Prevents modification of published history. ‣ Unique to file size and contents. Tags ‣ Cryptographically sign tags by GPG/email. Independence ‣ Separation from sequence # of checkin.
  51. 51. Location,Location,Location
  52. 52. Single Stage Thinking Subversion svn commit ‣ ‣ Adds everything modified. ‣ Must list if you want specific files. ‣ What if you check in your password?
  53. 53. $ echo //password >> Matt1.java $ echo //password >> Matt2.java
  54. 54. $ echo //password >> Matt1.java $ echo //password >> Matt2.java $ svn status M Matt1.java M Matt2.java
  55. 55. $ echo //password >> Matt1.java $ echo //password >> Matt2.java $ svn status M Matt1.java M Matt2.java $ svn commit -m'Matts checkin' Adding Matt1.java Adding Matt2.java Transmitting file data . Committed revision 2.
  56. 56. Remote is like a special Stash Repo Index Working
  57. 57. Remote is like a special Stash Repo Index Working
  58. 58. Remote is like a special Stash Repo git clone Index Working
  59. 59. Remote is like a special Stash Repo git clone git checkout Index Working
  60. 60. Remote is like a special Stash Repo git clone git checkout edit some files Index Working
  61. 61. Remote is like a special Stash Repo git clone git checkout edit some files git stash Index Working
  62. 62. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index Working
  63. 63. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index git stash apply Working
  64. 64. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index git stash apply Working git add
  65. 65. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index git stash apply Working git add git commit
  66. 66. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index git stash apply Working git add git commit git push
  67. 67. Remote is like a special Stash Repo git clone git checkout edit some files git stash edit some files Index git stash apply Working git add git commit git push
  68. 68. repo uild B git clone git://somedomain/myproj.git cd myproj.git
  69. 69. repo uild B git clone git://somedomain/myproj.git cd myproj.git dex te in pda U git checkout master
  70. 70. repo uild B git clone git://somedomain/myproj.git cd myproj.git dex te in pda U git checkout master king echo ‘//Comments’ >> ClassOne.java or dit w echo ‘//Thoughts’ >> ClassTwo.java E
  71. 71. repo uild B git clone git://somedomain/myproj.git cd myproj.git dex te in pda U git checkout master king echo ‘//Comments’ >> ClassOne.java or dit w echo ‘//Thoughts’ >> ClassTwo.java E ndex to i Add epo git add ClassOne.java to r ave comments’ S git commit -m’Added
  72. 72. repo uild B git clone git://somedomain/myproj.git cd myproj.git dex te in pda U git checkout master king echo ‘//Comments’ >> ClassOne.java or dit w echo ‘//Thoughts’ >> ClassTwo.java E ndex to i Add epo git add ClassOne.java to r ave commit -m’Added comments’ S git ash st h to stash Pus git
  73. 73. Three Stage Thinking Git git add ‣ git commit ‣ git push ‣ ‣ Commits only what is added to the index. ‣ Opportunity to change history locally. ‣ Selectively share with other repos.
  74. 74. $ echo //SECRETPASSWORD >> mattfile1.txt $ echo //NewText2 >> mattfile2.txt
  75. 75. $ echo //SECRETPASSWORD >> mattfile1.txt $ echo //NewText2 >> mattfile2.txt $ git status # On branch master # Changed but not updated: # modified: mattfile1.txt # modified: mattfile2.txt
  76. 76. $ echo //SECRETPASSWORD >> mattfile1.txt $ echo //NewText2 >> mattfile2.txt $ git status # On branch master # Changed but not updated: # modified: mattfile1.txt # modified: mattfile2.txt dex o in int Put $ git add mattfile1.txt
  77. 77. $ echo //SECRETPASSWORD >> mattfile1.txt $ echo //NewText2 >> mattfile2.txt $ git status # On branch master # Changed but not updated: # modified: mattfile1.txt # modified: mattfile2.txt dex o in int Put $ git add mattfile1.txt epo to r ave S $ git commit -m'Matts pw checkin' [master]: created ddcdf18: quot;Matts changesquot; 1 files changed, 1 insertions(+), 0 deletions(-)
  78. 78. #$%^&! I just committed my password!
  79. 79. Change History $ git reset --hard HEAD^ HEAD is now at 9de4cd3 First checkin $ git log commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993 Author: Matthew McCullough <matthewm@ambientideas.com> Date: Wed Mar 4 23:09:17 2009 -0700 First checkin
  80. 80. Change History mit com the way wa hro T $ git reset --hard HEAD^ HEAD is now at 9de4cd3 First checkin $ git log commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993 Author: Matthew McCullough <matthewm@ambientideas.com> Date: Wed Mar 4 23:09:17 2009 -0700 First checkin
  81. 81. Change History mit com the way wa hro T $ git reset --hard HEAD^ HEAD is now at 9de4cd3 First checkin $ git log commit 9de4cd3a3f24a3de3e804df84cc3321c7d0c9993 Author: Matthew McCullough <matthewm@ambientideas.com> Date: Wed Mar 4 23:09:17 2009 -0700 First checkin
  82. 82. GitMathematics
  83. 83. Directed Acyclic Graph a32 2e2 8b3 4e8
  84. 84. Directed Acyclic Graph Ann’s Feature a32 5fa 2e2 8b3 4e8
  85. 85. Directed Acyclic Graph Ann’s Feature a32 5fa 2e2 8b3 4e8
  86. 86. Directed Acyclic Graph Ann’s Feature a32 5fa Tim’s Feature 2e2 d19 8b3 4e8
  87. 87. Directed Acyclic Graph Ann’s Feature a32 5fa Tim’s Feature 2e2 d19 Linus’ rewrite of Tim’s feature 8b3 e69 4e8
  88. 88. Directed Acyclic Graph Ann’s Feature a32 5fa Tim’s Feature 2e2 d19 Linus’ rewrite of Tim’s feature 8b3 e69 4e8
  89. 89. Sharing
  90. 90. Serving It Up Network ‣ git instaweb. Built in, read-only, HTTP. ‣ git daemon. Custom socket language. ‣ gitosis. Easy permissions control. ‣ github. Open source & private repos. ‣ ssh. OS controlled permissions.
  91. 91. Serving It Up Filesystem ‣ Local folders. Yes, they can be “remotes.” ‣ Mapped network drives. Just like folders.
  92. 92. on aem it d g git clone git://somehost.org/myproj.git
  93. 93. on aem it d g git clone git://somehost.org/myproj.git SSH git clone mccm06@somehost.org:myproj.git
  94. 94. on aem it d g git clone git://somehost.org/myproj.git SSH git clone mccm06@somehost.org:myproj.git TTP H git clone http://somehost.org/myproj.git
  95. 95. on aem it d g git clone git://somehost.org/myproj.git SSH git clone mccm06@somehost.org:myproj.git TTP H git clone http://somehost.org/myproj.git tem sys File git clone ~/work/myproj.git
  96. 96. on aem it d g git clone git://somehost.org/myproj.git SSH git clone mccm06@somehost.org:myproj.git TTP H git clone http://somehost.org/myproj.git tem sys File git clone ~/work/myproj.git rive rk d two Ne git clone z:someservermyproj.git
  97. 97. Merge & Rebase
  98. 98. Cheap Branches
  99. 99. Cheap Branches git show-branch --all git branch -a ‣Local branch ‣localbranchname ‣Remote ‣remote/branchname
  100. 100. Merge Anything
  101. 101. Merge Anything git merge --no-commit <sourcebranch> git merge --squash <sourcebranch> git merge <sourcebranch1> <sourcebranch2> ‣Selectable merge strategy ‣Octopus: More than one ‣Review before committing ‣Flatten micro-checkins
  102. 102. Merge Strategies
  103. 103. Rebase for Clarity
  104. 104. Rebase for Clarity git checkout myfeaturebranch git rebase master ‣Cleaner history than a merge ‣Fast forwards original branch ‣Lets you see “how trunk will act” before you merge
  105. 105. WorkingOffline
  106. 106. Offline Anything Checkin
  107. 107. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove
  108. 108. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically everything but push
  109. 109. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically everything but push
  110. 110. Hooray! Another checkin to my latest OSS project!
  111. 111. Hooray! Another checkin to my latest OSS project! I think I liked subversion better...
  112. 112. Speed
  113. 113. Init Add Status Diff Branch (Cold/Hot) git hg bzr git hg bzr git hg bzr git hg bzr Tag Log Commit (Lg) Commit (Sm) git c git h hg c hg h bzr c bzr h git hg bzr git hg bzr git hg bzr git hg bzr data from http://whygitisbetterthanx.com/#git-is-fast
  114. 114. VCS Interop
  115. 115. Subversion git svn clone http://unfurl.com/trunk git svn dcommit ‣ First class compatibility. ‣ Round trip support. ‣ Git commits = svn commits.
  116. 116. UsageModels
  117. 117. Centralized Central Repo
  118. 118. Centralized Central Repo
  119. 119. Repo Blessed Dictatorship
  120. 120. Repo Blessed Dictatorship
  121. 121. Repo Blessed Dictatorship
  122. 122. Repo Blessed Dictatorship
  123. 123. Repo Blessed Dictatorship
  124. 124. Certified Integration Managed Development Repo Repo
  125. 125. Certified Integration Managed Development Repo Repo
  126. 126. Certified Integration Managed Development Repo Repo
  127. 127. Certified Integration Managed Development Repo Repo
  128. 128. Mirror Mirror Certified Development Repo Repo Mirrored
  129. 129. Mirror Mirror Certified Development Repo Repo Mirrored
  130. 130. Mirror Mirror Certified Development Repo Repo Mirrored
  131. 131. Mirror Mirror Certified Development Repo Repo Mirrored
  132. 132. Mirror Mirror Certified Development Repo Repo Mirrored
  133. 133. ☚ Private Public ☛ GitHub Custom + Public Contrib
  134. 134. ☚ Private Public ☛ GitHub Custom + Public Contrib
  135. 135. ☚ Private Public ☛ Customized GitHub Custom + Public Contrib
  136. 136. ☚ Private Public ☛ Customized GitHub Custom + Public Contrib
  137. 137. ☚ Private Public ☛ Customized GitHub Custom + Public Contrib
  138. 138. GUIs
  139. 139. GitX
  140. 140. gitSafe
  141. 141. GitK
  142. 142. GitGUI
  143. 143. 6 reasons
  144. 144. Cherry Pick ❻ ‣git cherry-pick a5b2ee
  145. 145. Cherry Pick ❻ ‣git cherry-pick a5b2ee ‣Merge in just one commit.
  146. 146. Cherry Pick ❻ ‣git cherry-pick a5b2ee ‣Merge in just one commit. ‣When you want a nugget, not a branchload.
  147. 147. Gives Credit ❺ ‣Tracks who authors a change.
  148. 148. Gives Credit ❺ ‣Tracks who authors a change. ‣“Author” even survives passing through reviewers.
  149. 149. Gives Credit ❺ ‣Tracks who authors a change. ‣“Author” even survives passing through reviewers. ‣“Author” survives all merges.
  150. 150. Gives Credit ❺ ‣Tracks who authors a change. ‣“Author” even survives passing through reviewers. ‣“Author” survives all merges. ‣Additionally tracks who committed a change.
  151. 151. Bisect Bugs ❹ ‣git bisect run mvn test
  152. 152. Bisect Bugs ❹ ‣git bisect run mvn test ‣Binary-search for bug.
  153. 153. Bisect Bugs ❹ ‣git bisect run mvn test ‣Binary-search for bug. ‣Manual or automated modes.
  154. 154. Bisect Bugs ❹ ‣git bisect run mvn test ‣Binary-search for bug. ‣Manual or automated modes. ‣Yak cruelty-prevention.
  155. 155. Squash Verbosity ❸ ‣git merge --squash mybranch
  156. 156. Squash Verbosity ❸ ‣git merge --squash mybranch ‣Reduce all your micro-checkins to block commits.
  157. 157. Squash Verbosity ❸ ‣git merge --squash mybranch ‣Reduce all your micro-checkins to block commits. ‣Make mistakes, revise, checkin without hesitation.
  158. 158. Squash Verbosity ❸ ‣git merge --squash mybranch ‣Reduce all your micro-checkins to block commits. ‣Make mistakes, revise, checkin without hesitation. ‣Great for SVN compatibility.
  159. 159. Search History ❷ ‣git grep SomeText HEAD^^^
  160. 160. Search History ❷ ‣git grep SomeText HEAD^^^ ‣Search in file history without checkout.
  161. 161. Search History ❷ ‣git grep SomeText HEAD^^^ ‣Search in file history without checkout. ‣Greps contents.
  162. 162. Rebase ❶ ‣git rebase master
  163. 163. Rebase ❶ ‣git rebase master ‣Reposition your feature branch’s start point.
  164. 164. Rebase ❶ ‣git rebase master ‣Reposition your feature branch’s start point. ‣Makes for simpler merge graphs.
  165. 165. Rebase ❶ ‣git rebase master ‣Reposition your feature branch’s start point. ‣Makes for simpler merge graphs. ‣Sustains feature-branch work clarity.
  166. 166. Tomorrow’s VCS, Today
  167. 167. tthew Ma Twitter @matthewmccull Blog http://www.ambientideas.com/blog sidebar has all my social media links Email matthewm@ambientideas.com GitHub http://github.com/matthewmccullough
  168. 168. Resources Git Homepage http://git-scm.com Directed Acrylic Graph http://en.wikipedia.org/wiki/Directed_acyclic_graph Git for Computer Scientists http://eagain.net/articles/git-for-computer-scientists/ Git Treeish http://book.git-scm.com/4_git_treeishes.html
  169. 169. Resources Git Docs http://www.kernel.org/pub/software/scm/git/docs/ Git Magic eBook http://www-cs-students.stanford.edu/~blynn/gitmagic/book.pdf Linus Torvald’s Git talk at Google http://www.youtube.com/watch?v=4XpnKHJAok8 CygWin http://www.cygwin.com
  170. 170. Resources MSysGit http://code.google.com/p/msysgit Git Cheetah http://code.google.com/p/msysgit/wiki/GitCheetah Matthew’s Git Bookmarks http://delicious.com/matthew.mccullough/git Matthew’s Bash Prompt http://gist.github.com/47267
  171. 171. Image Credits ‣ http://www.ambientideasphotography.com ‣ http://flickr.com/photos/lenore-m/2903856664/ ‣ http://en.wikipedia.org/wiki/Git_(software) ‣ http://flickr.com/photos/karenhorton/1583513014/ ‣ http://flickr.com/photos/mashdnart/2545782407/ ‣ http://commons.wikimedia.org/wiki/ File:Small_Boy_nuclear_test_1962.jpg ‣ http://www.flickr.com/photos/knmurphy/2506896257/ ‣ http://www.flickr.com/photos/albyspace/1022035568/ ‣ http://flickr.com/photos/michaelhays/3070238360/ ‣ http://flickr.com/photos/d_vdm/509996632/

×