Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Git: Beyond the Basics
Search
John Bohn
July 10, 2012
Programming
4
190
Git: Beyond the Basics
John Bohn
July 10, 2012
Tweet
Share
More Decks by John Bohn
See All by John Bohn
SOLID Design Principles in Ruby
jjbohn
2
100
Other Decks in Programming
See All in Programming
Perl 5 OOP機構30年史 - Perl 5's OOP Mechanism over the past 30 years
moznion
1
760
利用者視点で考える、イテレータとの上手な付き合い方
syumai
4
210
CSC509 Lecture 03
javiergs
PRO
0
120
pytest プラグインを開発して DRY に自動テストを書こう
inuatsu
2
220
RemixとCloudflare Stack におけるFile Upload
ossamoon
1
120
Progressive Web Apps for Rails developers
siaw23
2
510
"Swarming" をコンセプトに掲げるアジャイルチームのベストプラクティス
boykush
1
110
色んなオートローダーを覗き見る #phpcon_okinawa
o0h
PRO
5
350
CSC509 Lecture 02
javiergs
PRO
0
140
Iteratorでページネーションを実現する
sonatard
3
690
はじめてみよう量子プログラミング
itokoichi01
0
280
sqlcを利用してsqlに型付けを
kamiyam
0
220
Featured
See All Featured
Code Review Best Practice
trishagee
62
16k
How to Think Like a Performance Engineer
csswizardry
16
1k
Pencils Down: Stop Designing & Start Developing
hursman
119
11k
Facilitating Awesome Meetings
lara
49
6k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
25
640
Web Components: a chance to create the future
zenorocha
309
42k
YesSQL, Process and Tooling at Scale
rocio
167
14k
Automating Front-end Workflow
addyosmani
1365
200k
A Philosophy of Restraint
colly
202
16k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
32k
Embracing the Ebb and Flow
colly
83
4.4k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
36
1.7k
Transcript
gitbeyond the basics Thursday, August 2, 12
John Bohn @jjbohn Thursday, August 2, 12
Developer at OpenSky curated social commerce Thursday, August 2, 12
git what is Thursday, August 2, 12
git is fast and lightweight free/open source distributed crazy simple
Thursday, August 2, 12
init branch add commit merge Thursday, August 2, 12
Almost any VCS works does this (more or less) What
is special about git? Thursday, August 2, 12
Interactivity Thursday, August 2, 12
git add --patch git add --interactive Thursday, August 2, 12
Arduino Example Thursday, August 2, 12
Change Blink Thursday, August 2, 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
git add --patch Thursday, August 2, 12
git add --patch Thursday, August 2, 12
git add --patch Thursday, August 2, 12
git add --patch Commit the change Thursday, August 2, 12
git add --patch Stage other changes Diff is now empty
(everything is staged or commited) Thursday, August 2, 12
git stash Thursday, August 2, 12
is super boring Thursday, August 2, 12
until you throw some flags at it... Thursday, August 2,
12
git stash --no-keep-index git stash --keep-index git stash --patch git
stash --include-untracked My Favorites Thursday, August 2, 12
Finding these commands is just a matter of digging Thursday,
August 2, 12
git anything --help Thursday, August 2, 12
git reset is not git revert Thursday, August 2, 12
git reset --soft [sha] git reset --hard [sha] git reset
--mixed [sha] Thursday, August 2, 12
You can also: git reset --patch (but not with those
modes) Thursday, August 2, 12
Bisecting aka: Finding a commit that screwed things up. Thursday,
August 2, 12
Bisecting Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 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 cfc332 Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 Tell git what is
known good and bad cfc332 good bad Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad Thursday,
August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good
Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good
good Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good
good 2ab1f is most likely good because the commit after it is Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good
good bad Thursday, August 2, 12
Bisecting 7b35b 91296 9680d 2ab1f c6d43 cfc332 good bad good
good bad bad Thursday, August 2, 12
Recovering lost commits Thursday, August 2, 12
git reflog Thursday, August 2, 12
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
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
Recovery Found it! 3ecdba3 Thursday, August 2, 12
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
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
Recovery Checkout the reflog again to see the cherry-pick Thursday,
August 2, 12
Interactive Rebasing Changing the past one commit at a time
Thursday, August 2, 12
git rebase -i [commit] Thursday, August 2, 12
git rebase -i [commit] Thursday, August 2, 12
git rebase -i [commit] Thursday, August 2, 12
git rebase -i [commit] Thursday, August 2, 12
Interactive rebase Thursday, August 2, 12
git internals The plumbing and the porcelain Thursday, August 2,
12
git internals git stores snapshots, not differences Storing differences is
slow and inflexible CVS/Subversion git Thursday, August 2, 12
git internals git stores snapshots, not differences Storing differences is
slow and inflexible CVS/Subversion git Thursday, August 2, 12
git internals What does a commit look like? Thursday, August
2, 12
git internals Let’s investigate a repo Sorry for the bad
“investigation” image ;-) Thursday, August 2, 12
Thanks! Come work with me at OpenSky! We’re Hiring Thursday,
August 2, 12