Git: Beyond the Basics

484 views

Published on

Git Beyond the Basics with John Bohn

One thing that makes git a great version control systems is its low barrier to entry, but there's so much more to learn. We'll start with a very brief intro to git and quickly move onto some more fun and advanced topics such as recovering lost commits, rebasing, bisecting, bookmarking and more. Come learn some valuable tips and tricks that are sure to same you time and headaches.

A second generation developer working at OpenSky, John Bohn is an open source contributor and advocate of anything that gets the job done better and faster.

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

  • Be the first to like this

No Downloads
Views
Total views
484
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git: Beyond the Basics

  1. 1. git beyond the basicsThursday, August 2, 12
  2. 2. John Bohn @jjbohnThursday, August 2, 12
  3. 3. Developer at OpenSky curated social commerceThursday, August 2, 12
  4. 4. what is gitThursday, August 2, 12
  5. 5. git is fast and lightweight free/open source distributed crazy simpleThursday, August 2, 12
  6. 6. init branch add commit mergeThursday, August 2, 12
  7. 7. Almost any VCS works does this (more or less) What is special about git?Thursday, August 2, 12
  8. 8. InteractivityThursday, August 2, 12
  9. 9. git add --patch git add --interactiveThursday, August 2, 12
  10. 10. Arduino ExampleThursday, August 2, 12
  11. 11. Change BlinkThursday, August 2, 12
  12. 12. Change Blink - Two logical changes - Don’t want to bother undoing one - Can’t git add . or git add [file]Thursday, August 2, 12
  13. 13. git add --patchThursday, August 2, 12
  14. 14. git add --patchThursday, August 2, 12
  15. 15. git add --patchThursday, August 2, 12
  16. 16. git add --patch Commit the changeThursday, August 2, 12
  17. 17. git add --patch Stage other changes Diff is now empty (everything is staged or commited)Thursday, August 2, 12
  18. 18. git stashThursday, August 2, 12
  19. 19. is super boringThursday, August 2, 12
  20. 20. until you throw some flags at it...Thursday, August 2, 12
  21. 21. My Favorites git stash --no-keep-index git stash --keep-index git stash --include-untracked git stash --patchThursday, August 2, 12
  22. 22. Finding these commands is just a matter of diggingThursday, August 2, 12
  23. 23. git anything --helpThursday, August 2, 12
  24. 24. git reset is not git revertThursday, August 2, 12
  25. 25. git reset --soft [sha] git reset --hard [sha] git reset --mixed [sha]Thursday, August 2, 12
  26. 26. You can also: git reset --patch (but not with those modes)Thursday, August 2, 12
  27. 27. Bisecting aka: Finding a commit that screwed things up.Thursday, August 2, 12
  28. 28. BisectingThursday, August 2, 12
  29. 29. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 6 Commits - One Bug We know that 7b35b is good We know that cfc332 is bad But we have no idea where the bug was introducedThursday, August 2, 12
  30. 30. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good bad Tell git what is known good and badThursday, August 2, 12
  31. 31. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good badThursday, August 2, 12
  32. 32. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good good badThursday, August 2, 12
  33. 33. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good good good badThursday, August 2, 12
  34. 34. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good good good bad 2ab1f is most likely good because the commit after it isThursday, August 2, 12
  35. 35. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good good good bad badThursday, August 2, 12
  36. 36. Bisecting 7b35b 2ab1f 9680d 91296 c6d43 cfc332 good good good bad bad badThursday, August 2, 12
  37. 37. Recovering lost commitsThursday, August 2, 12
  38. 38. git reflogThursday, August 2, 12
  39. 39. git reflog Technically shows any action where the tip of a branch is modified git reflog --all shows stashes, bisects, etc.Thursday, August 2, 12
  40. 40. Recovery Let’s say I reset --hard and wiped out the commit that changed my LED to pin 10 Use combination of reflog and cherry-pick to get it backThursday, August 2, 12
  41. 41. Recovery Found it! 3ecdba3Thursday, August 2, 12
  42. 42. Recovery Double check that 3ecdba3 is really the commit we want git diff 3ecdba3^.. 3ecdba3 Shows me the difference between the commit I want to cherry pick and the commit prior.Thursday, August 2, 12
  43. 43. git cherry-pick Now cherry pick 3ecdba3 into our working tree Note: the sha has changed because this commit now has a different parent than it did when it was recorded into the reflogThursday, August 2, 12
  44. 44. Recovery Checkout the reflog again to see the cherry-pickThursday, August 2, 12
  45. 45. Interactive Rebasing Changing the past one commit at a timeThursday, August 2, 12
  46. 46. git rebase -i [commit]Thursday, August 2, 12
  47. 47. git rebase -i [commit]Thursday, August 2, 12
  48. 48. git rebase -i [commit]Thursday, August 2, 12
  49. 49. git rebase -i [commit]Thursday, August 2, 12
  50. 50. Interactive rebaseThursday, August 2, 12
  51. 51. git internals The plumbing and the porcelainThursday, August 2, 12
  52. 52. git internals git stores snapshots, not differences Storing differences is slow and inflexible CVS/Subversion gitThursday, August 2, 12
  53. 53. git internals git stores snapshots, not differences Storing differences is slow and inflexible CVS/Subversion gitThursday, August 2, 12
  54. 54. git internals What does a commit look like?Thursday, August 2, 12
  55. 55. git internals Let’s investigate a repo Sorry for the bad “investigation” image ;-)Thursday, August 2, 12
  56. 56. Thanks! Come work with me at OpenSky! We’re HiringThursday, August 2, 12

×