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
受け取る人から提供する人になるということ
little_rubyist
0
250
Click-free releases & the making of a CLI app
oheyadam
2
120
リアーキテクチャxDDD 1年間の取り組みと進化
hsawaji
1
220
C++でシェーダを書く
fadis
6
4.1k
Generative AI Use Cases JP (略称:GenU)奮闘記
hideg
1
300
Quine, Polyglot, 良いコード
qnighy
4
650
flutterkaigi_2024.pdf
kyoheig3
0
150
ヤプリ新卒SREの オンボーディング
masaki12
0
130
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Less waste, more joy, and a lot more green: How Quarkus makes Java better
hollycummins
0
100
型付き API リクエストを実現するいくつかの手法とその選択 / Typed API Request
euxn23
8
2.2k
Ethereum_.pdf
nekomatu
0
460
Featured
See All Featured
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
131
33k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
38
1.8k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
Designing for Performance
lara
604
68k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
47
2.1k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
The Power of CSS Pseudo Elements
geoffreycrofte
73
5.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
840
Being A Developer After 40
akosma
87
590k
Six Lessons from altMBA
skipperchong
27
3.5k
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