Git going    with    DVCS               nutes oc          90 mi ol magi f    source code contr                    by Matth...
MatthewMcCullough
http://ambientideas.com/blog
http://presentationpatterns.com
http://orei.ly/ogitvid
http://www.wakaleo.com/books/continuous-     integration-with-hudson-the-book
http://delicious.com/matthew.mccullough/git
Git
“Cool kids” version control system
Open Source
bash scripts   C code
≉
“ Git -noun                     asa nt     ish Sla ng. an u nple Brit                      er son”      cont   empt    ibl...
otistical b astard, and“Im an eg    I name all my projects    after myself. Fi rst Linux,    now   git. ”                 ...
CertifiedGit User
145+ commands
18 used ona daily basis
init     checkout   bisectlog      revert     clonerebase   pack       diffmerge    pull       grepcommit   push       tag...
Distributed Version Control        A new idea?
1997code co-op
2001 arch
2003monotone
2003 SVK
2003 darcs
2005bazaar
2005mercurial
2005 git
Why?
m s                                                  ste                                              l sy                ...
“   hated it with a p assion...    ...no w ay to do C VS right.                -Linu s Torvalds                           ...
Why switch to    Git     ?
Safely Be Wrong  Experiment Innovate  Drive-by AssistCrowd Source
and...
integration builds
integration builds
Hashes and Git
Index vs Hash‣ Centralized VCS uses DB  sequential index.
Index vs Hash‣ Git uses SHA-1 hash.
40 hex characters
9AB223D28B1AA46EF1780B22F304982E39872C34
use as little of it as is unique
9AB223D28B1AA46EF1780B22F304982E39872C34
9AB223D28B1AA46EF1780B22F304982E39872C34
treeish
treeish = shorthand for hashes
9AB223
9AB223^
HEAD
HEAD^
HEAD~3
--since="2 weeks ago"
9AB223..56CD77
Hashable Objects‣ Blob‣ Tree‣ Commit‣ Tag
8d162 c67db   commit                                           7e8b1                                                      ...
Distributedconnectivity
developer A
developer A   developer B
developer A   developer B
developer A   developer B
blessed repodeveloper A                  developer B
Three Stage Thinking
Working         Staging       Repo                 checkout          add                     commit                       ...
RemoteStash                Repo             Index   Working
RemoteStash                Repo             Index   Working
RemoteStash                Repo                       git clone             Index   Working
RemoteStash                Repo                       git clone                       git checkout             Index   Wor...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
RemoteStash                Repo                       git clone                       git checkout                       e...
WorkingOffline
More available connectivity
More available connectivity
More demand to work without    connectivity
More demand to work without    connectivity
Offline Anything Checkin
Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically ever...
Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically ever...
Matthew: Cool! Another commit to mylatest OSS project using         Git!
Matthew: Cool!             Another commit to my            latest OSS project using                     Git!Madelaine: I l...
Storage Mechanics
Typical SCMs use deltas
v1       v2       v3       v4       v5File A            File A            File AFile B   File B   File B   File B   File B...
CVS / Subversion / darcs / Mercurial
Checkin                           ckin                                             kin                  in                ...
Git uses Directed Acyclic Graph storage                 (DAG)
cp -r srcfolder srcfolder.prev
Copy of the entire tree per checkin
zlib deflates every blob at commit
symlinks to existing identical blobs
v1       v2       v3       v4       v5File A   File A   File A   File A   File AFile B   File B   File B   File B   File B...
400MB Subversion repo convert to a 70MB Git repo
Speed
http://whygitisbetterthanx.com
Init               Add               Status               Diff                                                            ...
Init                              Status            Diff                                                                  ...
10 to     100 times       Faster
Branch, Merge & Rebase
Branch
Cheap Branchesgit branch newbranch
Merge
Merges lump branch changes into anew unified commit
M                 da             S er                   r              ta g                    d                n eMaster/...
ard    d   n e ta g                                     a32         Bra                                                   ...
Merge Anythinggit merge --no-commit <sourcebranch>
Merge Anythinggit merge --squash <sourcebranch>
Merge Anythinggit merge <sourcebranch1> <sourcebranch2>
Rebase
Not a merge
simulates team members taking turns working               (one person at a time)
Rebase for Claritygit checkout myfeaturebranchgit rebase master
RebasingMaster/Trunk/MainLatest
sing                             a32   Bra                                              n   ch eba           Master/Trunk/...
Master/Trunk/MainLatest                           a32                    2e2              8b3             Bra             ...
Master/Trunk/MainLatest                          a32                   2e2             8b3           Bra          ch  n
a32Master/Trunk/MainLatest                          2e2                          8b3   Bra                                ...
Master/Trunk/MainLatest                            a32                     2e2               8b3e69        d19
Who’s Got   Git?
UsageModels
CentralizedCentral Repo
CentralizedCentral Repo
Repo               BlessedDictatorship
Repo               BlessedDictatorship
Repo               BlessedDictatorship
Repo               BlessedDictatorship
Repo               BlessedDictatorship
Certified                         Integration Managed           Development Repo         Repo
Certified                         Integration Managed           Development Repo         Repo
Certified                         Integration Managed           Development Repo         Repo
Certified                         Integration Managed           Development Repo         Repo
Private            Public                   GitHubCustom + Public Contrib
Private            Public                   GitHubCustom + Public Contrib
Private             Public         Customized                      GitHubCustom + Public Contrib
Private             Public         Customized                      GitHubCustom + Public Contrib
SVN Interop
arguably the best feature of git
use git in stealth mode
Subversiongit svn clone http://unfurl.com/trunk//Hack, hack,   hackgit commit -a   -m‘Some changes’git commit -a   -m‘More...
Subversion‣ First class compatibility.‣ Round trip support.‣ Git commits = svn commits.
effortlessly convert full historywhen ready to migrate the team
Migrationgit svn clone http://unfurl.com/trunk
MigrationYou now have a full git clone of the SVN repo
MigrationPower off your Subversion server
3reasons
Cherry Pick             !‣git cherry-pick a5b2ee‣Merge in just one commit.
Cherry Pick             !‣git cherry-pick a5b2ee‣Merge in just one commit.
Search History             "‣git grep SomeText HEAD^^^‣Search blob contents history without checkouts.
Search History             "‣git grep SomeText HEAD^^^‣Search blob contents history without checkouts.
Bisect Bugs                #‣git bisect run mvn test‣Binary-search for bug via failed tests.‣Manual or automated modes.‣An...
Bisect Bugs                #‣git bisect run mvn test‣Binary-search for bug via failed tests.‣Manual or automated modes.‣An...
Twitter @matthewmccull             MatthewBlog http://www.ambientideas.com/blog         sidebar has all my social media li...
Image Credits‣   http://www.ambientideasphotography.com‣   http://flickr.com/photos/lenore-m/2903856664/‣   http://en.wikip...
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Git Going with DVCS v1.6.0
Upcoming SlideShare
Loading in...5
×

Git Going with DVCS v1.6.0

1,834

Published on

Git introduction to the Dallas Java MUG

Published in: Education, Technology

Git Going with DVCS v1.6.0

  1. 1. Git going with DVCS nutes oc 90 mi ol magi f source code contr by Matthew McCullough of Ambient Ideas, LLC
  2. 2. MatthewMcCullough
  3. 3. http://ambientideas.com/blog
  4. 4. http://presentationpatterns.com
  5. 5. http://orei.ly/ogitvid
  6. 6. http://www.wakaleo.com/books/continuous- integration-with-hudson-the-book
  7. 7. http://delicious.com/matthew.mccullough/git
  8. 8. Git
  9. 9. “Cool kids” version control system
  10. 10. Open Source
  11. 11. bash scripts C code
  12. 12.
  13. 13. “ Git -noun asa nt ish Sla ng. an u nple Brit er son” cont empt ible p or English D ictionar y -Oxford
  14. 14. otistical b astard, and“Im an eg I name all my projects after myself. Fi rst Linux, now git. ” -Lin us Torvalds
  15. 15. CertifiedGit User
  16. 16. 145+ commands
  17. 17. 18 used ona daily basis
  18. 18. init checkout bisectlog revert clonerebase pack diffmerge pull grepcommit push tagadd status branch
  19. 19. Distributed Version Control A new idea?
  20. 20. 1997code co-op
  21. 21. 2001 arch
  22. 22. 2003monotone
  23. 23. 2003 SVK
  24. 24. 2003 darcs
  25. 25. 2005bazaar
  26. 26. 2005mercurial
  27. 27. 2005 git
  28. 28. Why?
  29. 29. m s ste l sy tro Subversion on n c rsio Perforce veSource d Clear ize Safe Case a l CVS t r PVCS e n RCSC Folders
  30. 30. “ hated it with a p assion... ...no w ay to do C VS right. -Linu s Torvalds ”
  31. 31. Why switch to Git ?
  32. 32. Safely Be Wrong Experiment Innovate Drive-by AssistCrowd Source
  33. 33. and...
  34. 34. integration builds
  35. 35. integration builds
  36. 36. Hashes and Git
  37. 37. Index vs Hash‣ Centralized VCS uses DB sequential index.
  38. 38. Index vs Hash‣ Git uses SHA-1 hash.
  39. 39. 40 hex characters
  40. 40. 9AB223D28B1AA46EF1780B22F304982E39872C34
  41. 41. use as little of it as is unique
  42. 42. 9AB223D28B1AA46EF1780B22F304982E39872C34
  43. 43. 9AB223D28B1AA46EF1780B22F304982E39872C34
  44. 44. treeish
  45. 45. treeish = shorthand for hashes
  46. 46. 9AB223
  47. 47. 9AB223^
  48. 48. HEAD
  49. 49. HEAD^
  50. 50. HEAD~3
  51. 51. --since="2 weeks ago"
  52. 52. 9AB223..56CD77
  53. 53. Hashable Objects‣ Blob‣ Tree‣ Commit‣ Tag
  54. 54. 8d162 c67db commit 7e8b1 blob 7D 8D B3 7F BD 12 9F E9 a10b3 tree 7B 78 9D 3F 5C A6 72 CBtree:parent:author: a10b3 nil Fird tree blob: 8d162 logo.jpgcommitter: Matthew 51d22 blob: 51d22 draw.jsmessage:Major refactoring tree: blob: 7e8b1 web 9ab16 index.html blobof the web content. //Some more javascript 9ab16 var renderSize <html> blob <body></body> </html>
  55. 55. Distributedconnectivity
  56. 56. developer A
  57. 57. developer A developer B
  58. 58. developer A developer B
  59. 59. developer A developer B
  60. 60. blessed repodeveloper A developer B
  61. 61. Three Stage Thinking
  62. 62. Working Staging Repo checkout add commit Three stage thinking
  63. 63. RemoteStash Repo Index Working
  64. 64. RemoteStash Repo Index Working
  65. 65. RemoteStash Repo git clone Index Working
  66. 66. RemoteStash Repo git clone git checkout Index Working
  67. 67. RemoteStash Repo git clone git checkout edit project files Index Working
  68. 68. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash Index Working
  69. 69. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash test bug on master Index working as designed Working
  70. 70. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash test bug on master Index working as designed git stash apply Working
  71. 71. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash test bug on master Index working as designed git stash apply Working git add
  72. 72. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash test bug on master Index working as designed git stash apply Working git add git commit
  73. 73. RemoteStash Repo git clone git checkout edit project files boss interrupts git stash test bug on master Index working as designed git stash apply Working git add git commit git push
  74. 74. WorkingOffline
  75. 75. More available connectivity
  76. 76. More available connectivity
  77. 77. More demand to work without connectivity
  78. 78. More demand to work without connectivity
  79. 79. Offline Anything Checkin
  80. 80. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically everything but push
  81. 81. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically everything but push
  82. 82. Matthew: Cool! Another commit to mylatest OSS project using Git!
  83. 83. Matthew: Cool! Another commit to my latest OSS project using Git!Madelaine: I like subversionmuch better...
  84. 84. Storage Mechanics
  85. 85. Typical SCMs use deltas
  86. 86. v1 v2 v3 v4 v5File A File A File AFile B File B File B File B File BFile C File C Storage
  87. 87. CVS / Subversion / darcs / Mercurial
  88. 88. Checkin ckin kin in Chec kin he ck ec C he in in Ch C ck k C he h ec kin C ec ec kinDelta storage gets slower as the hhistory Ch C Checkin of a file gets longer Checkin
  89. 89. Git uses Directed Acyclic Graph storage (DAG)
  90. 90. cp -r srcfolder srcfolder.prev
  91. 91. Copy of the entire tree per checkin
  92. 92. zlib deflates every blob at commit
  93. 93. symlinks to existing identical blobs
  94. 94. v1 v2 v3 v4 v5File A File A File A File A File AFile B File B File B File B File BFile C File C File C File C File C Storage
  95. 95. 400MB Subversion repo convert to a 70MB Git repo
  96. 96. Speed
  97. 97. http://whygitisbetterthanx.com
  98. 98. 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 hgit hg bzr git hg bzr git hg bzr git hg bzr data from http://whygitisbetterthanx.com/#git-is-fast
  99. 99. Init Status Diff Branchgit svn git svn git svn Tag Log Commit (Lg) Commit (Sm) git c svn cgit svn git svn git svn git svn data from http://whygitisbetterthanx.com/#git-is-fast
  100. 100. 10 to 100 times Faster
  101. 101. Branch, Merge & Rebase
  102. 102. Branch
  103. 103. Cheap Branchesgit branch newbranch
  104. 104. Merge
  105. 105. Merges lump branch changes into anew unified commit
  106. 106. M da S er r ta g d n eMaster/Trunk/MainLatest a32
  107. 107. ard d n e ta g a32 Bra n chS er Master/Trunk/MainLatest d19 M 2e2 e69 8b3 erge M d19 9f1 e69
  108. 108. Merge Anythinggit merge --no-commit <sourcebranch>
  109. 109. Merge Anythinggit merge --squash <sourcebranch>
  110. 110. Merge Anythinggit merge <sourcebranch1> <sourcebranch2>
  111. 111. Rebase
  112. 112. Not a merge
  113. 113. simulates team members taking turns working (one person at a time)
  114. 114. Rebase for Claritygit checkout myfeaturebranchgit rebase master
  115. 115. RebasingMaster/Trunk/MainLatest
  116. 116. sing a32 Bra n ch eba Master/Trunk/MainLatestR 2e2 d19 8b3 e69
  117. 117. Master/Trunk/MainLatest a32 2e2 8b3 Bra ch n d19e69Rebase
  118. 118. Master/Trunk/MainLatest a32 2e2 8b3 Bra ch n
  119. 119. a32Master/Trunk/MainLatest 2e2 8b3 Bra n ch d19 e69
  120. 120. Master/Trunk/MainLatest a32 2e2 8b3e69 d19
  121. 121. Who’s Got Git?
  122. 122. UsageModels
  123. 123. CentralizedCentral Repo
  124. 124. CentralizedCentral Repo
  125. 125. Repo BlessedDictatorship
  126. 126. Repo BlessedDictatorship
  127. 127. Repo BlessedDictatorship
  128. 128. Repo BlessedDictatorship
  129. 129. Repo BlessedDictatorship
  130. 130. Certified Integration Managed Development Repo Repo
  131. 131. Certified Integration Managed Development Repo Repo
  132. 132. Certified Integration Managed Development Repo Repo
  133. 133. Certified Integration Managed Development Repo Repo
  134. 134. Private Public GitHubCustom + Public Contrib
  135. 135. Private Public GitHubCustom + Public Contrib
  136. 136. Private Public Customized GitHubCustom + Public Contrib
  137. 137. Private Public Customized GitHubCustom + Public Contrib
  138. 138. SVN Interop
  139. 139. arguably the best feature of git
  140. 140. use git in stealth mode
  141. 141. Subversiongit svn clone http://unfurl.com/trunk//Hack, hack, hackgit commit -a -m‘Some changes’git commit -a -m‘More changes’git commit -a -m‘Final changes’git svn dcommit
  142. 142. Subversion‣ First class compatibility.‣ Round trip support.‣ Git commits = svn commits.
  143. 143. effortlessly convert full historywhen ready to migrate the team
  144. 144. Migrationgit svn clone http://unfurl.com/trunk
  145. 145. MigrationYou now have a full git clone of the SVN repo
  146. 146. MigrationPower off your Subversion server
  147. 147. 3reasons
  148. 148. Cherry Pick !‣git cherry-pick a5b2ee‣Merge in just one commit.
  149. 149. Cherry Pick !‣git cherry-pick a5b2ee‣Merge in just one commit.
  150. 150. Search History "‣git grep SomeText HEAD^^^‣Search blob contents history without checkouts.
  151. 151. Search History "‣git grep SomeText HEAD^^^‣Search blob contents history without checkouts.
  152. 152. Bisect Bugs #‣git bisect run mvn test‣Binary-search for bug via failed tests.‣Manual or automated modes.‣Ant, Maven, or shell script that can return 0 or 1-127
  153. 153. Bisect Bugs #‣git bisect run mvn test‣Binary-search for bug via failed tests.‣Manual or automated modes.‣Ant, Maven, or shell script that can return 0 or 1-127
  154. 154. Twitter @matthewmccull MatthewBlog http://www.ambientideas.com/blog sidebar has all my social media linksEmail matthewm@ambientideas.comGitHub http://github.com/matthewmccullough
  155. 155. 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/

×