Git Going With DVCS v1.5.2

3,057 views

Published on

Git presentation to the Utah Java Users Group (UJUG)

Published in: Education, Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,057
On SlideShare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
116
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Git Going With DVCS v1.5.2

  1. 1. Git going with DVCS mental spoo n bending 50 minutes of v ia source c ode control by Matthew McCullough of Ambient Ideas, LLC
  2. 2. What? Why? Basic Use GUI DVCS Who? Theory Sharing Interop High Points
  3. 3. “ Git -noun sant or Slang. an unplea British cont emptible per son ” ionar y -Oxfo rd English Dict
  4. 4.
  5. 5. otistical b astard, and “ I'm an eg I name all my projects after myself. Fi rst Linux, now git. ” -Lin us Torvalds
  6. 6. darcs Mercurial Bazaar BitKeeper Subversion Perforce Clear Source Case Safe CVS PVCS RCS Folders
  7. 7. t Source Code Control Gi
  8. 8. CultureChange
  9. 9. Centralized VCS =Don’t
  10. 10. Distributed VCS = Whatever! Do
  11. 11. Innovate Experiment Safely Be Wrong Drive-by Assist Crowd Source
  12. 12. Crowd Source
  13. 13. Download binaries
  14. 14. Git Distro Sources Win Cygwin Win msysGit Linux Source Linux Package manager Mac MacPorts Mac git-osx-installer Any JGit
  15. 15. Put it in your path
  16. 16. Identify yourself
  17. 17. Global Git Settings git config --global user.name quot;Hal Smithquot; git config --global user.email quot;hal@bnl.comquot;
  18. 18. Use it!
  19. 19. Creating a Repo mkdir myproj.git cd myproj.git git init
  20. 20. Just show it to me!
  21. 21. Certified Git User
  22. 22. 145+ Commands
  23. 23. Follow the DOTS
  24. 24. Symmetric
  25. 25. subversion server developer A developer B
  26. 26. ch ec ki n
  27. 27. te da up
  28. 28. n ki ec ch
  29. 29. up da te
  30. 30. Symmetric
  31. 31. Distributed
  32. 32. developer A developer B
  33. 33. blessed repo developer A developer B
  34. 34. commit commit commit commit commit commit commit
  35. 35. delete delete
  36. 36. rebase
  37. 37. pu sh
  38. 38. pu sh
  39. 39. push
  40. 40. push
  41. 41. pull
  42. 42. pull
  43. 43. Distributed
  44. 44. WorkingOffline
  45. 45. More available connectivity
  46. 46. More demand to work without connectivity
  47. 47. Offline Anything Checkin Add Branch List change log Grep history Rewrite history Stash Merge Label Remove practically everything but push
  48. 48. Cool! Another commit to my latest OSS project using Git! I liked subversion better...
  49. 49. What? Why? Basic Use GUIs DVCS Who? Theory Sharing Interop High Points
  50. 50. Who’s Got Git?
  51. 51. GUIs
  52. 52. GitX
  53. 53. GitSafe
  54. 54. GitK
  55. 55. GitGUI
  56. 56. EGit
  57. 57. c i a l ! O f fi It ’s
  58. 58. UsageModels
  59. 59. Centralized Central Repo
  60. 60. Repo Blessed Dictatorship
  61. 61. Certified Integration Managed Development Repo Repo
  62. 62. Mirror Mirror Certified Development Repo Repo Mirrored
  63. 63. ☚ Private Public ☛ Customized GitHub Custom + Public Contrib
  64. 64. Hashes and Git
  65. 65. Index vs Hash ‣ Centralized VCS uses DB sequential index.
  66. 66. Index vs Hash ‣ Git uses SHA-1 hash.
  67. 67. ght thou re I ashe s we h for wor ds? p ass
  68. 68. SHA-1 Hash ‣ Different goals. ‣ Hash for the sake of integrity. ‣ Hash for the sake of identity.
  69. 69. 40 hex characters
  70. 70. Use as little of it as is unique
  71. 71. Treeish
  72. 72. Shorthand for the hashes
  73. 73. 9AB223
  74. 74. 9AB223^
  75. 75. 9AB223..56CD77
  76. 76. HEAD
  77. 77. HEAD^
  78. 78. HEAD~3
  79. 79. ve b seen B ut I’ ring new hea ash abo ut h ision s... coll
  80. 80. 49 to m s rt h a e a
  81. 81. 46 S H A 1
  82. 82. 22 s ta rs
  83. 83. 20 g ra in s s an d
  84. 84. 19 l is io n c o l
  85. 85. Hashable Objects ‣ Blob ‣ Tree ‣ Commit ‣ Tag
  86. 86. http://book.git-scm.com/1_the_git_object_model.html
  87. 87. Hash Benefits Integrity ‣ Identifies damaged repos. ‣ Prevents modification of published history. ‣ Unique to file size and contents.
  88. 88. Hash Benefits Tags ‣ Cryptographically sign tags by GPG. ‣ Guarantee repo’s state at a point in time.
  89. 89. Storage Mechanics
  90. 90. Typical SCMs use delta storage
  91. 91. CVS / Subversion / darcs / Mercurial
  92. 92. 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 kin Delta storage gets slower Ch the Ch as history of a file gets longerin Checkin Check
  93. 93. Git uses DAG storage
  94. 94. Directed Acyclic Graph
  95. 95. Copy of the entire tree per checkin
  96. 96. cp -r srcfolder srcfolder.prev
  97. 97. Sounds inefficient...
  98. 98. zlib deflates every blob at commit
  99. 99. I’ve had a 400MB Subversion repo convert to a 70MB Git repo
  100. 100. Speed
  101. 101. git: git hg: mercurial bzr: bazaar
  102. 102. 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
  103. 103. bazaar numbers subversion = plus network latency
  104. 104. 10 to 100 times Faster
  105. 105. Location,Location,Location
  106. 106. Three Stage Thinking of Git
  107. 107. Git ‣ git add ‣ git commit ‣ git push
  108. 108. ‣ Commits only what is added to the index. ‣ Opportunity to rewrite history locally. ‣ Provides time to change your mind. ‣ Selectively share with other repos.
  109. 109. Git ‣ git stash ‣ git stash apply
  110. 110. ‣ Save work-in-progress temporarily, but safely. ‣ Merge stashed modifications back in.
  111. 111. Remote is like a special Stash Repo git clone git checkout edit experiment files git stash test buggy files Index git stash apply Working git add git commit git push
  112. 112. repo git clone git://somedomain/myproj.git B uild cd myproj.git dex pda te in git checkout master U echo ‘//Comments’ >> ClassOne.java or king echo ‘//Thoughts’ >> ClassTwo.java E dit w to i ndex git add ClassOne.java Add epo ave to r git commit -m’Added comments’ S st ash git stash Pus h to
  113. 113. Merge & Rebase
  114. 114. Cheap Branches git branch newbranch git checkout -b newer remote/branchnm
  115. 115. Cheap Branches git show-branch --all git branch -a
  116. 116. ‣Local branch ‣localbranchname ‣Remote branch ‣remote/branchname
  117. 117. Merge Anything git merge --no-commit <sourcebranch> git merge --squash <sourcebranch> git merge <sourcebranch1> <sourcebranch2>
  118. 118. Rebase for Clarity git checkout myfeaturebranch git rebase master
  119. 119. Rebase for Clarity ‣Fast forwards the “side” branch. ‣Reposition your feature branch’s start point. ‣See “how trunk will act” before you merge. ‣Makes for simpler merge graphs. ‣Cleaner history than a merge.
  120. 120. ard Bra d n e ta g a32 n ch S er Master/Trunk/MainLatest d19 M 2e2 e69 8b3 erge M 9f1
  121. 121. Bra sing a32 n ch ba Master/Trunk/MainLatest Re 2e2 d19 8b3 e69
  122. 122. Master/Trunk/MainLatest a32 2e2 8b3 Bra ch n d19 e69 Rebase
  123. 123. a32 Master/Trunk/MainLatest 2e2 8b3 Bra n ch d19 d19 Me rg e e69 e69
  124. 124. What? Why? Basic Use GUIs DVCS Who? Theory Sharing Interop High Points
  125. 125. Sharing
  126. 126. Serving It Up Protocols ‣ GIT ‣ SSH ‣ SCP ‣ Local file system ‣ SAMBA ‣ HTTP ‣ WebDAV ‣ rsync
  127. 127. aem on git clone git://somehost.org/myproj.git g it d git clone mccm06@somehost.org:myproj.git SSH git clone http://somehost.org/myproj.git H TTP sys tem git clone ~/work/myproj.git File rk d rive Ne two git clone z:someservermyproj.git
  128. 128. Serving It Up ‣ 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.
  129. 129. SVN Interop
  130. 130. Subversion git svn clone http://unfurl.com/trunk git svn dcommit
  131. 131. Subversion ‣ First class compatibility. ‣ Round trip support. ‣ Git commits = svn commits.
  132. 132. Migration ‣ git svn clone
  133. 133. Migration ‣ Power off your Subversion server.
  134. 134. 3 reasons
  135. 135. Cherry Pick ❸ ‣git cherry-pick a5b2ee ‣Merge in just one commit.
  136. 136. Search History ❷ ‣git grep SomeText HEAD^^^ ‣Search blob contents history without checkouts.
  137. 137. Bisect Bugs ❶ ‣git bisect run mvn test ‣Binary-search for bug. ‣Manual or automated modes.
  138. 138. emerging Control System Version
  139. 139. Twitter @matthewmccull Matthew Blog http://www.ambientideas.com/blog sidebar has all my social media links Email matthewm@ambientideas.com GitHub http://github.com/matthewmccullough
  140. 140. 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
  141. 141. 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
  142. 142. 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
  143. 143. 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/

×