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
Commandless Git
Search
Alex Tercete
April 07, 2015
Programming
1
210
Commandless Git
Having a basic understanding of how Git works is the key to taking the most out of it.
Alex Tercete
April 07, 2015
Tweet
Share
More Decks by Alex Tercete
See All by Alex Tercete
Making Makefiles
alextercete
0
64
Shipping containers
alextercete
0
52
Parallelism and Symmetry
alextercete
0
200
Porting to .NET Standard
alextercete
0
53
Prepping Commits
alextercete
1
120
The end of your line-endings nightmare
alextercete
0
170
I love sushi, therefore I love rebase
alextercete
0
99
ReadyRoll for DotNet developers
alextercete
0
84
Coding Dojo: The Randori Kata
alextercete
1
470
Other Decks in Programming
See All in Programming
subpath importsで始めるモック生活
10tera
0
310
Tauriでネイティブアプリを作りたい
tsucchinoko
0
370
3 Effective Rules for Using Signals in Angular
manfredsteyer
PRO
0
100
OnlineTestConf: Test Automation Friend or Foe
maaretp
0
110
ローコードSaaSのUXを向上させるためのTypeScript
taro28
1
620
Laravel や Symfony で手っ取り早く OpenAPI のドキュメントを作成する
azuki
2
120
Quine, Polyglot, 良いコード
qnighy
4
640
受け取る人から提供する人になるということ
little_rubyist
0
230
Make Impossible States Impossibleを 意識してReactのPropsを設計しよう
ikumatadokoro
0
170
AWS IaCの注目アップデート 2024年10月版
konokenj
3
3.3k
Better Code Design in PHP
afilina
PRO
0
130
CSC509 Lecture 13
javiergs
PRO
0
110
Featured
See All Featured
The Cult of Friendly URLs
andyhume
78
6k
Bootstrapping a Software Product
garrettdimon
PRO
305
110k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
The World Runs on Bad Software
bkeepers
PRO
65
11k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
96
Six Lessons from altMBA
skipperchong
27
3.5k
Rails Girls Zürich Keynote
gr2m
94
13k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Large-scale JavaScript Application Architecture
addyosmani
510
110k
Teambox: Starting and Learning
jrom
133
8.8k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
890
Into the Great Unknown - MozCon
thekraken
32
1.5k
Transcript
Commandless Git https://www.flickr.com/photos/sfxeric/4578550858
Alex Tercete @alextercete Rio de Janeiro, Brazil EnergyHelpline
https://www.flickr.com/photos/cdevers/3292421477
https://www.flickr.com/photos/cdevers/4618787095
https://www.flickr.com/photos/cdevers/4618786545
Simplified Model
Engine Fuel Transmission Wheels Brakes Steering
Engine Fuel Transmission Wheels Brakes Steering
Engine Fuel Transmission Wheels Brakes Steering
Engine Fuel Transmission Wheels Brakes Steering
Brakes Engine Fuel Transmission Wheels Steering
Makes things intuitive
Brakes Engine Fuel Transmission Wheels Steering Brake
Brakes Engine Fuel Transmission Wheels Steering
Brakes Engine Fuel Transmission Wheels Steering
It works, but not as it was meant to
Brakes Engine Fuel Transmission Wheels Steering
Brakes Engine Fuel Transmission Wheels Steering
None
Working directory Staging area path/to/A.txt path/to/B.txt Files database Add
Working directory Staging area path/to/A.txt path/to/B.txt Files database
Working directory Staging area path/to/A.txt path/to/B.txt Files database Hash generation
SHA1 c3
Working directory Staging area path/to/A.txt path/to/B.txt Files database Hash generation
c3 SHA1
Working directory Staging area path/to/A.txt path/to/B.txt Files database c3
Working directory Staging area path/to/A.txt path/to/B.txt Files database c3
Working directory Staging area path/to/A.txt c3 path/to/A.txt path/to/B.txt Files database
c3
Working directory Staging area path/to/A.txt c3 path/to/A.txt path/to/B.txt Files database
c3 Hash generation SHA1 ed
Working directory Staging area path/to/A.txt c3 path/to/A.txt path/to/B.txt Files database
c3 Hash generation SHA1 ed ed
c3 ed Files database Working directory Staging area path/to/A.txt c3
path/to/A.txt path/to/B.txt
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
c3 ed path/to/A.txt path/to/B.txt
– Hash is generated for the file’s content – Generated
hash is the same for identical inputs – Files are saved to the files database – Changes are added to the staging area Add
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
c3 ed path/to/A.txt path/to/B.txt Commit
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
c3 ed path/to/A.txt path/to/B.txt
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
c3 ed path/to/A.txt path/to/B.txt Hash generation SHA1 ca c3 ed
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
c3 ed path/to/A.txt path/to/B.txt Hash generation SHA1 ca c3 ed path/to/A.txt path/to/B.txt c3 ed Commit ca
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
path/to/A.txt path/to/B.txt c3 ed Commit ca
c3 ed Files database Working directory Staging area Commit ca
path/to/A.txt path/to/B.txt path/to/A.txt path/to/B.txt c3 ed Commits tree ca
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt
c3 ed Files database Working directory Staging area path/to/A.txt Commits
tree ca path/to/B.txt other/path/to/C.txt
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt path/to/B.txt other/path/to/C.txt 17 2b 17 2b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt path/to/B.txt other/path/to/C.txt 17 2b 17 2b Hash generation SHA1 c3 17 7b 2b ca path/to/A.txt path/to/B.txt c3 17 Commit 7b other/path/to/C.txt 2b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b path/to/A.txt path/to/B.txt c3 17 Commit 7b other/path/to/C.txt 2b 7b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b 7b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b 7b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b 7b other/path/to/C.txt 6d 6d
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b 7b other/path/to/C.txt 6d 6d Hash generation SHA1 c3 17 6d path/to/A.txt path/to/B.txt c3 17 Commit 33 other/path/to/C.txt 6d 33 7b
c3 ed Files database Working directory Staging area path/to/A.txt path/to/B.txt
Commits tree ca other/path/to/C.txt 17 2b 7b 6d 33
– Hash is generated combining • Hash of the parent
commit • Hashes of the files in the commit – Points to every file tracked by the repository – Staging area is cleared after the commit – Gets added to the commits tree Commit
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 Branch
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33 8e
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 33 master 33 feature/something 33 8e 4c
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c ff
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 4c master 33 feature/something 4c 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
– HEAD indicates the current commit being pointed to –
There is nothing special about master – When on a branch, the reference gets updated after a commit Branch
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54 Checkout
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca 17 2b 7b 6d 33 References HEAD ca master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
c3 ed Files database Working directory path/to/A.txt path/to/B.txt Commits tree
ca other/path/to/C.txt 17 2b 7b 6d 33 References HEAD 54 master 33 feature/something 54 8e 4c ff 54
– Only HEAD moves – Files are copied from the
files database into the working directory – Files database remains unaltered – Commits tree remains unaltered Checkout
Files database Commits tree ca 7b 33 References HEAD 54
master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff Merge
Files database Commits tree ca 7b 33 References HEAD 54
master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff
Files database Commits tree ca 7b 33 References HEAD 33
master 33 feature/something 54 4c 54 c3 ed 17 2b 6d 8e ff
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Merge NO CONFLICTS
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD 2f
master 2f feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 2f
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Merge WITH CONFLICTS
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD b5
master b5 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 57 b5
– Brings changes from other branch into current branch –
Conflict resolution is done once – Commit has two parents Merge
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Rebase NO CONFLICTS
Files database Commits tree ca 7b 33 References HEAD e6
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD 54
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD a2
master e6 feature/something 54 a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 54
Files database Commits tree ca 7b 33 References HEAD 9f
master e6 feature/something 54 a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 9f 54
Files database Commits tree ca 7b 33 References HEAD 9f
master e6 feature/something 9f a2 e6 c3 ed 17 2b 6d 8e ff 98 4c 9f 54
Files database Commits tree ca 7b 33 References HEAD 54
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98 Rebase WITH CONFLICTS
Files database Commits tree ca 7b 33 References HEAD 54
master e6 feature/something 54 4c 54 e6 c3 ed 17 2b 6d 8e ff 98
Files database Commits tree ca 7b 33 References HEAD dd
master e6 feature/something 54 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f
Files database Commits tree ca 7b 33 References HEAD b8
master e6 feature/something 54 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f b8
Files database Commits tree ca 7b 33 References HEAD b8
master e6 feature/something b8 dd e6 c3 ed 17 2b 6d 8e ff 98 4c 54 7f b8
– Puts changes introduced by current branch onto other branch
– Conflict resolution is done for each commit – No extra commits are made Rebase
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Push
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33
– There is nothing special about origin – Tracking branch
gets updated before uploading data to the remote – The remote is just another repository Push
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 Fetch
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master 33 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa 62 b0
Files database Commits tree ca 7b 33 References HEAD 33
master 33 c3 ed 17 2b 6d origin http://url Remotes Remote origin Files database Commits tree origin/master b0 c3 ed 17 2b 6d ca 7b 33 62 b0 0e fa 0e fa 62 b0
– Tracking branch gets updated after downloading data from the
remote – Merge or rebase can be performed afterwards Fetch
https://www.flickr.com/photos/inthe-arena/15501000164
Reset Stash Revert
http://git-scm.com/book
Alex Tercete @alextercete speakerdeck.com/alextercete/commandless-git
Thank you! https://www.flickr.com/photos/sfxeric/4578550858