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
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
200
Duckdb-Wasmでローカルダッシュボードを作ってみた
nkforwork
0
100
Better Code Design in PHP
afilina
PRO
0
110
僕がつくった48個のWebサービス達
yusukebe
20
17k
Java ジェネリクス入門 2024
nagise
0
690
プロジェクト新規参入者のリードタイム短縮の観点から見る、品質の高いコードとアーキテクチャを保つメリット
d_endo
1
1.1k
Tauriでネイティブアプリを作りたい
tsucchinoko
0
350
cXML という電子商取引の トランザクションを支える プロトコルと向きあっている話
phigasui
3
2.3k
PLoP 2024: The evolution of the microservice architecture pattern language
cer
PRO
0
2.4k
Why Jakarta EE Matters to Spring - and Vice Versa
ivargrimstad
0
600
What’s New in Compose Multiplatform - A Live Tour (droidcon London 2024)
zsmb
1
450
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
8
5k
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
246
1.3M
GitHub's CSS Performance
jonrohan
1030
460k
Ruby is Unlike a Banana
tanoku
96
11k
Documentation Writing (for coders)
carmenintech
65
4.4k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Designing the Hi-DPI Web
ddemaree
280
34k
For a Future-Friendly Web
brad_frost
175
9.4k
How GitHub (no longer) Works
holman
310
140k
A Philosophy of Restraint
colly
203
16k
A designer walks into a library…
pauljervisheath
202
24k
It's Worth the Effort
3n
183
27k
Scaling GitHub
holman
458
140k
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