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
subpath importsで始めるモック生活
10tera
0
300
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
タクシーアプリ『GO』のリアルタイムデータ分析基盤における機械学習サービスの活用
mot_techtalk
4
1.4k
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Contemporary Test Cases
maaretp
0
140
GitHub Actionsのキャッシュと手を挙げることの大切さとそれに必要なこと
satoshi256kbyte
5
430
見せてあげますよ、「本物のLaravel批判」ってやつを。
77web
7
7.7k
Streams APIとTCPフロー制御 / Web Streams API and TCP flow control
tasshi
2
350
[Do iOS '24] Ship your app on a Friday...and enjoy your weekend!
polpielladev
0
100
3rd party scriptでもReactを使いたい! Preact + Reactのハイブリッド開発
righttouch
PRO
1
600
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
とにかくAWS GameDay!AWSは世界の共通言語! / Anyway, AWS GameDay! AWS is the world's lingua franca!
seike460
PRO
1
860
Featured
See All Featured
Building Adaptive Systems
keathley
38
2.3k
Intergalactic Javascript Robots from Outer Space
tanoku
269
27k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
109
49k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
42
9.2k
How to Ace a Technical Interview
jacobian
276
23k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
89
StorybookのUI Testing Handbookを読んだ
zakiyama
27
5.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
48
48k
How STYLIGHT went responsive
nonsquared
95
5.2k
Adopting Sorbet at Scale
ufuk
73
9.1k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
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