Getting Git Right

80,450 views

Published on

When you get Git right, it can help you write cleaner code, roll out new features faster, and make your entire development team more efficient.

Published in: Technology
3 Comments
128 Likes
Statistics
Notes
  • Pro Git --- http://amzn.to/1RsRDKI
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Version Control with Git: Powerful tools and techniques for collaborative software development --- http://amzn.to/22qrnWK
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Ry's Git Tutorial --- http://amzn.to/25cZS1F
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
80,450
On SlideShare
0
From Embeds
0
Number of Embeds
1,046
Actions
Shares
0
Downloads
668
Comments
3
Likes
128
Embeds 0
No embeds

No notes for slide

Getting Git Right

  1. Who knows ?
  2. Facts 500 Developers
  3. 1000+ Nerds Facts
  4. working on 9 products Facts
  5. or in just 3 words We Software
  6. We SoftwareTeams
  7. they know what’s going on! really small team Let’s do it! Great idea! Productivity++
  8. Productivity? team is growing Let’s do it! Great! Why? Who will do it? Is it done? Have you talked to QA? I have no time for this!
  9. Productivity?? we’re not alone Is it profitable? When is it done?
  10. Devel ping S ftware is a S cial Challenge
  11. happy developers & productive teams Ship software Tools faster & smarter
  12. Ship software faster & smarter happy developers & productive teams
  13. All sorts of teams are on &
  14. All sort of teams
  15. Migrating soon? http://atlassian.com/git/
  16. is just a tool!
  17. Happier Developer with Be a
  18. Time machine without paradoxes?
  19. Why does make you happy? 2 Freedom & Safety Explore & Understand 1 3 Fast & Compact 4 Control and Assemble
  20. But Why? Or How?
  21. A lot of the “Why” can be explained at the Conceptual model
  22. Written in C by Linux kernel and filesystem developers
  23. 5 minutes dive into internals
  24. Git is fundamentally a content-addressable filesystem with a VCS user interface written on top of it Pro Git Book, Section: Git Inter nals ” “
  25. cba0a.. commit tree blob content blob content blob content 98ca9.. 92ec2.. 5b1d3.. 911e7.. cba0a.. tree 92ec2.. blob 5b1d3.. blob 911e7.. blob author committer README LICENSE test.rb size size size size size parent data model r34ti..
  26. $> tree .git/objects .git/objects ├── info └── pack 2 directories
  27. git add some-file.txt
  28. $> tree .git/objects .git/objects ├── e4 │ └── 3a6ac59164adadac854d591001bbb10086f37d ├── info └── pack 3 directories, 1 file zlib compressed SHA1
  29. git commit -m "First commit"
  30. $> tree .git/objects .git/objects ├── 13 │ └── 1e360ae1a0c08acd18182c6160af6a83e0d22f ├── 31 │ └── 995f2d03aa31ee97ee2e814c9f0b0ffd814316 ├── e4 │ └── 3a6ac59164adadac854d591001bbb10086f37d ├── info └── pack 5 directories, 3 files Commit Tree Blob
  31. cba0a.. commit tree blob content blob content blob content 98ca9.. 92ec2.. 5b1d3.. 911e7.. cba0a.. tree 92ec2.. blob 5b1d3.. blob 911e7.. blob author committer README LICENSE test.rb size size size size size parent data model r34ti..
  32. data model commit tree c4d.. author message: 1st! tree blob 5b1d3.. blob 911e7.. blob cba0a.. size size READM LICENS test.rb parent … commit tree c4d.. author message: Update! parent 8efc8.. tree blob 5b1d3.. blob 911e7.. blob cba0a.. size size READM LICENS test.rb … commit tree c4d.. author message: More! parent bc5e7.. tree blob 5b1d3.. blob 911e7.. blob cba0a.. size size READM LICENS test.rb … …
  33. echo "// Comment" >> some-file.txt
  34. git add some-file.txt
  35. $> tree .git/objects .git/objects ├── 13 │ └── 1e360ae1a0c08acd18182c6160af6a83e0d22f ├── 31 │ └── 995f2d03aa31ee97ee2e814c9f0b0ffd814316 ├── c1 │ └── 9e6823e34980033917b6427f3e245ce2102e6e ├── e4 │ └── 3a6ac59164adadac854d591001bbb10086f37d 6 directories, 4 files Entirely new BLOB
  36. wat?
  37. git gc
  38. $> tree .git/objects .git/objects ├── info │ └── packs └── pack ├── pack-7475314b451a882d77b1535d215def8bad0f4306.idx └── pack-7475314b451a882d77b1535d215def8bad0f4306.pack 2 directories, 3 files
  39. Loose Objects Packfile 1. zlib compressed 2. Delta encoded
  40. Fast and Compact
  41. Everything is local Except push & pull
  42. Read: FAST
  43. But what if my repo is big? 2 12,000 non-merge commits 446k lines of code added 1 3 Linux Kernel release has 15+ million LOC 4 1,339 contributors source lwn.net
  44. Control and Assemble
  45. What is a merge? merges keep the context of the feature’s commits M Merge commit feature master feature master
  46. Anatomy of a merge .git/objects/36/80d8c8fd182f97cb0e75045e2fed5c7b7613ed tree f362c42032aff677c1a09c3f070454df5b411239 parent 49a906f5722ad446a131778cea52e3fda331b706 parent bd1174cd0f30fe9be9efdd41dcd56256340f230e author Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 committer Marcus Bertrand <mbertrand@atlassian.com> 1409002123 -0700 Merge branch 'foo/mybranch' commit
  47. merge is better in git git knows the ancestry 1 2 The merge is local 3 powerful merge strategies
  48. Let’s talk about merge strategies! git has breadth of choice on how to merge changes! resolve recursive octopus ours subtree yours?
  49. What is a fast-forward merge? It will just shift the HEAD tag master feature master feature
  50. merge strategy: resolve Three-way merge of the ancestors feature Common ancestor master M Merge commit
  51. merge strategy: recursive 3-way merge but climbs the ancestry tree recursively if there are multiple ancestors M M master feature ancestor 1 ancestor 3 ancestor 2
  52. merge strategy: ours Records a merge but skips incoming changes feature master M IGNORE!
  53. use “ours” to promote more recent branches
  54. merge becomes a non-event
  55. rebase: Rewrite history with safety belts on
  56. What is a rebase? It’s a way to replay commits, one by one, on top of a branch master feature
  57. When you use merge… You pollute your feature branch with non-meaningful merge commits not really part of feature… feature master meaningful merge
  58. What is a rebase? It can be used to keep a feature branch up to date with master feature master
  59. What is an --interactive rebase? Helps you clean up your private branches before publishing them reword fixup pick squash edit exec
  60. CUSTOMARY WARNING! rebase rewrites history! Treat this power with great care. Only rewrite history of local branches or…
  61. So what do I use? merge or rebase?
  62. Merge Commit Rebase (FF) Rebase (Squash) No merge commits Verbose history Easy to read Can be more difficult to trace changes Which should I use? “Ugly” history Full traceability Hard to screw up mostly some
  63. Read more on the topic! bit.do/merge-or-rebase
  64. Pro tips for the road
  65. Everyone has their favorite, but! Liquid prompt is awesome http://bit.do/liquid-prompt
  66. Get all the alias goodness on Bitbucket http://bit.do/git-aliases
  67. Why does make you happy? 2 Freedom & Safety Explore & Understand 1 3 Fast & Compact 4 Control and Assemble
  68. Happy Developerwith A
  69. Productive Teamwith A
  70. Why makes a team great! 2 Improving Code Quality Protect Code 1 3 Efficient Workflows 4 Git & Your Toolchain
  71. Efficient Workflows
  72. Can we still fix a bug for the upcoming Release ? Is the code for that Feature complete? How do we do Hotfix for the current version? Has everyoneReviewed the code for this feature ?
  73. We don’t know! What’s the best Git workflow?
  74. different cultures + different products + different teams = different workflows What’s the best Git workflow?
  75. Design your own Workflows
  76. Issues Code
  77. Issues Code JIRA-123 JIRA-123 JIRA-456 JIRA-456
  78. Can’t be released right now Unfinished features in your trunk / master branch
  79. Branch per issue First: feature/JIRA-30 stable master branch isolated feature work master
  80. Branch per issue First: feature/JIRA-30-user-avatars branch type issue key description
  81. Branch per issue First: bugfix/JIRA-31-oauth-3lo-NPE branch type issue key description
  82. Branch per issue First: hotfix/JIRA-32-broke-ie8-again branch type issue key description
  83. Typos happne! Tool switching sucks
  84. Is the branch green? Branch name pre-populated
  85. Confounding build breakages master
  86. Confounding build breakages bugfix/JRA-1 master
  87. Is the branch green? Branch name pre-populated
  88. SAAS Workflow 1 Atlassian Marketplace Workflow
  89. Simplest Workflow release from here master feature/JIRA-30 feature/JIRA-45
  90. Simplest Workflow release from here master develop feature/JIRA-30 feature/JIRA-45 integrate here
  91. Installable software 2 Atlassian Stash Workflow
  92. Multiple Product Versions v 1.1 v 1.2 master feature/JIRA-30
  93. Multiple Product Versions v 1.1 bugfix/JIRA-41 v 1.2 master
  94. Multiple Product Versions v 1.1 bugfix/JIRA-41 v 1.2 master
  95. Multiple Product Versions bugfix/JIRA-45 v 1.1 v 1.2 master
  96. Multiple Product Versions bugfix/JIRA-45 v 1.1 v 1.2 master
  97. Multiple Product Versions bugfix/JIRA-45 v 1.1 v 1.2 master boring work
  98. Automatic merges with a Git hook https://bitbucket.org/durdn/automatic-merge-hook
  99. Automatic merges with Stash
  100. Nearly everything is possible with Design your workflow
  101. Improving Code Quality
  102. Photo: Yogi (Flickr) RCeovdieew
  103. Have you ever been sitting in a long review session?
  104. Felt uncomfortable when your code was discussed?
  105. Better Code Shared Knowledge Team Ownership Code Review
  106. Developer guilt G = 1 R+1
  107. Code Reviews
  108. Pull Requests 
  109. Pull Requests
  110. Pull Requests do it before merge
  111. Pull Request Creation
  112. Pull Request Creation
  113. Pull Request Creation
  114. Pull Request Creation Discuss
  115. Discuss your changes
  116. Side by side diff the choice is yours
  117. Merge
  118. Merge wait!
  119. Pull Request Merge Checks
  120. Who would be the best to review my code?
  121. Auto Suggest Reviewers Free Add On For
  122. Suggestions: committed code to this Pull Request contributed files that were modified
  123. Make Code Reviews part of your daily work asynchronously less painful
  124. Protect Code without slowing you down
  125. Control access to your repositories
  126. Permissions for Repositories          Users & Groups Repositories
  127. Permissions for Repositories          Projects Users & Groups
  128. Permissions for Repositories          Projects Users & Groups
  129. Permissions for Repositories          Projects Users & Groups
  130. Pure Permissions for Repositories Repository Manger - visual interface - role based - file system access - SSH - HTTPS
  131. Repository Manger Less time configuring and waiting more time to code
  132. People can change code - You control the input
  133. Forks The way to allow changes & protect your code
  134. Server side clone of the repository  
  135. Server side clone of the repository  
  136. Pull request to contribute changes  
  137. Protect your repo
  138. No protection The Git Dude
  139. master <deploy on green build to production> branch everyone can read & branch master feature/IRKD-30 Branch Permissions with
  140. Branch Permissions with master <deploy on green build to production> branch master feature/IRKD-30 only allowed by trusted devs
  141. Branch Permissions with
  142. Know your priorities Security DevSpeed
  143. Git and your Toolchain
  144. & CI
  145. Running builds on feature branches experiment on your feature branch
  146. Running builds on feature branches keep your master branch green experiment on your feature branch
  147. try to remember You’ll forget to set up the build in your feature branch!
  148. Auto detect branches
  149. x developer times x push to remote = lots of builds (waiting)
  150. Running builds on feature branches automatically v 1.2 master feature/IRKD-30 manually
  151. branch pull merge
  152. Report the status!
  153. branch pull merge IN PROGRESS IN REVIEW DONE
  154. JUST LET ME CODE!
  155. branch pull merge IN PROGRESS IN REVIEW DONE
  156. TO DO IN PROGRESS IN REVIEW DONE Branch Commit Pull Request Open… Pull Request … Merged
  157. What’s the status? Issue Status Issue Tracker Pull Request Build Status Git Manager Build Server Deploy Status Config Manager
  158. Development Info
  159. Development Info Branch
  160. Development Info Branch Commit Build Failed…
  161. Development Info Branch Commit Build Failed… Successful Pull request Open…
  162. Development Info Branch Commit Build Failed… Successful Pull request Open… Merged
  163. Development Info Branch Commit Build Failed… Successful Pull request Open… Merged Deploy
  164. JUST LET ME CODE!
  165. JUST LET ME CODE!
  166. All Development Info Real Time Notification History Discussions
  167. See what’s going on with
  168. See what’s going on Builds with
  169. Bots See what’s going on with
  170. Pages See what’s going on with
  171. Why Git?Everything is awesome
  172. Why Git?Everything is awesome Doesn’t convince everyone
  173. Why Git? More time to code Better collaboration Dev productivity The future Economics Deliver software faster Less bugs Happy customers
  174. Why Git? Ship software faster & smarter

×