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 In A Tree
Search
Daniel Öberg
November 13, 2011
Programming
7
340
Git In A Tree
An illustrated guide to Git
Daniel Öberg
November 13, 2011
Tweet
Share
Other Decks in Programming
See All in Programming
AWS Lambdaから始まった Serverlessの「熱」とキャリアパス / It started with AWS Lambda Serverless “fever” and career path
seike460
PRO
0
130
Importmapを使ったJavaScriptの 読み込みとブラウザアドオンの影響
swamp09
4
1.3k
Googleのテストサイズを活用したテスト環境の構築
toms74209200
0
300
破壊せよ!データ破壊駆動で考えるドメインモデリング / data-destroy-driven
minodriven
17
4.3k
Java ジェネリクス入門 2024
nagise
0
690
Boost Performance and Developer Productivity with Jakarta EE 11
ivargrimstad
0
1.5k
Nurturing OpenJDK distribution: Eclipse Temurin Success History and plan
ivargrimstad
0
440
Pinia Colada が実現するスマートな非同期処理
naokihaba
4
200
AI時代におけるSRE、 あるいはエンジニアの生存戦略
pyama86
4
980
C#/.NETのこれまでのふりかえり
tomokusaba
1
180
Realtime API 入門
riofujimon
0
140
Hotwire or React? ~Reactの録画機能をHotwireに置き換えて得られた知見~ / hotwire_or_react
harunatsujita
8
5.1k
Featured
See All Featured
Music & Morning Musume
bryan
46
6.2k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
364
24k
Fashionably flexible responsive web design (full day workshop)
malarkey
404
65k
GitHub's CSS Performance
jonrohan
1030
460k
How GitHub (no longer) Works
holman
310
140k
The MySQL Ecosystem @ GitHub 2015
samlambert
250
12k
Reflections from 52 weeks, 52 projects
jeffersonlam
346
20k
A Tale of Four Properties
chriscoyier
156
23k
Being A Developer After 40
akosma
86
590k
The Language of Interfaces
destraynor
154
24k
Six Lessons from altMBA
skipperchong
26
3.5k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
27
810
Transcript
Git Sitting In A Tree An illustrated guide to Git.
Nothingness git init
Nothingness echo “Duck” > README.txt README.txt
Tell git about our duck git add README.txt Staging Area
README.txt Duck
Save git commit -m “I wrote ‘Duck’ into README.txt” Staging
Area README.txt Duck Commit commit message
Save git commit -m “I wrote ‘Donald Duck’ into README.txt”
Staging Area README.txt Duck Commit Duck
Why not directly? README.txt Duck Commit Duck
Git hates us README.txt Duck Commit Duck
Git hates us Git has opinions
“If you deny the Index [staging area], you really deny
git itself.” - Linus Torvalds
Reason Splits your code into two sections: Code that has
been reviewed for a commit Code that hasn’t
Reason Splits your code into two sections: Code in the
staging area Code not in the staging area
Example I implemented both a new feature and a bug-fix
and forgot to commit them.
I’m happily coding echo "bug-fix" >> README.txt echo "new feature"
>> README.txt cat README.txt duck bug-fix new feature
Committing the feature only git add --patched README.txt && git
commit -m “Feature added” Staging Area README.txt new feature Commit Duck new feature new feature
Seeing what’s left git diff @@ -1,2 +1,3 @@ duck
+bug-fix new feature Really, really useful
Committing that git add README.txt && git commit -m “Bug
squashed” Staging Area README.txt bug-fix Commit Duck new feature bug-fix bug-fix
Send Specific Patch Now I can freely choose to send
a patch that contains only the bug-fix to my boss (he can have the new feature on his birthday). Duck new feature bug-fix
Remove Specific Patch ‘New feature’ might have contained a serious
bug. I can the remove the new feature without touching the bug-fix. Amazing, you say. Duck new feature bug-fix
Take A Sip Of Coffee
Again
Staging Area/Index We always commit by first adding or removing
files to the Index
git add Adds files content to the staging area. Staging
Area README.txt Duck
git add --patch Adds some part (it will ask you)
of the files to the staging area. Staging Area README.txt new feature
git rm Removes all the files content from the staging
area. Staging Area README.txt Duck
git diff Shows the difference between the staging area and
the working directory. Staging Area README.txt Diff
git commit -m “msg” Commit file content in staging area
with a description/message Staging Area README.txt Commit *
Good Work
Gotchas
git add Git has a list of files. By running
git add you also append the filenames given to this list. Nasty, nasty, nasty. Lots of confusion from this feature.
git commit -a This is the reason for tracking the
files. By adding an -a you tell git to add all its tracked files file contents to the staging area and then commit it all.
And A Lie
Staging Area What we call a staging area, Git officially
calls the Index.
Thanks for listening
United Lambdas Daniel Öberg
[email protected]