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.
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 introduced
Thursday, August 2, 12
30. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good bad
Tell git what is known good and bad
Thursday, August 2, 12
31. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good bad
Thursday, August 2, 12
32. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good good bad
Thursday, August 2, 12
33. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good good good bad
Thursday, August 2, 12
34. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good good good bad
2ab1f is most likely good because the commit after it is
Thursday, August 2, 12
35. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good good good bad bad
Thursday, August 2, 12
36. Bisecting
7b35b 2ab1f 9680d 91296 c6d43 cfc332
good good good bad bad bad
Thursday, August 2, 12
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. 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 back
Thursday, August 2, 12
41. Recovery
Found it! 3ecdba3
Thursday, August 2, 12
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. 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 reflog
Thursday, August 2, 12
44. Recovery
Checkout the reflog again to see the cherry-pick
Thursday, August 2, 12
45. Interactive Rebasing
Changing the past
one commit at a
time
Thursday, August 2, 12