SlideShare a Scribd company logo
1 of 53
git internals
dbyrne
23andMe
agenda
1.data ... in two commits
a. blobs
b. trees
c. commits
2.algorithms ... in six commits
a. commit
b. branch
c. merge
d. reset
objects
commits
trees
blobs
objects, blobs
$ git init objects_example
$ cd objects_example
$ echo "puts 'hello world'" > foo.rb
$ git add foo.rb
$ strings .git/index | grep hello
$ strings .git/index | grep foo.rb
foo.rb
objects, blobs
$ find .git/objects -type file
.git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
$ git cat-file -t aaaa # what type of object is this?
blob
$ git cat-file -p aaaa # print the object
puts 'hello world'
objects, blobs
$ echo "puts 'hello world'" > bar.rb
$ git add bar.rb
$ strings .git/index | grep bar.rb
bar.rb
$ find .git/objects -type file # no new blob
.git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
objects
$ git commit -m 'commit msg #1'
$ find .git/objects -type file
.git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.git/objects/bb/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
.git/objects/cc/cccccccccccccccccccccccccccccccccccccc
objects, trees
$ git cat-file -t bbbb
tree
$ git cat-file -p bbbb
100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bar.rb
100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa foo.rb
objects, commits
$ git cat-file -t cccc
commit
$ git cat-file -p cccc
tree bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
author dbyrne <dennis.byrne@gmail.com> 1474171822 -0700
committer dbyrne <dennis.byrne@gmail.com> 1474171822 -0700
commit msg #1
c
a
b
foo.rb bar.rb
objects
$ mkdir dir
$ echo "puts 'hello world'" > dir/baz.rb
$ git add dir/baz.rb
$ git commit -m 'commit msg #2'
objects
$ find .git/objects -type file
.git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
.git/objects/bb/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
.git/objects/cc/cccccccccccccccccccccccccccccccccccccc
.git/objects/dd/dddddddddddddddddddddddddddddddddddddd <- new
.git/objects/ee/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee <- new
.git/objects/ff/ffffffffffffffffffffffffffffffffffffff <- new
objects
$ git cat-file -p HEAD^{commit} # same as ffff
tree eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
parent cccccccccccccccccccccccccccccccccccccccc
author dbyrne <dennis.byrne@gmail.com> 1474172113 -0700
committer dbyrne <dennis.byrne@gmail.com> 1474172113 -0700
commit msg #2
objects
$ git cat-file -p HEAD^{tree} # same as eeee
100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bar.rb
040000 tree dddddddddddddddddddddddddddddddddddddddd dir
100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa foo.rb
objects
$ git cat-file -t dddd
tree
$ git cat-file -p dddd
100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa baz.rb
c
a
b /
f
e /
d /dir
foo.rb
bar.rb
baz.rb
foo.rb bar.rb
objects
there are three types of objects: blobs, trees & commits
blobs represent files
blobs are created with the add, not the commit command
blobs are snapshots, not deltas or patches
the add command records snapshots every time
a file can be both “staged” and “modified”
trees represent directories
trees point to blobs and/or trees
refs
$ ls .git/HEAD
.git/HEAD <- important
$ tree .git/refs/
├── heads <- important
│ └── master
├── remotes
├── stash
└── tags
git commit
$ git init refs_example
$ cd refs_example
$ echo "print 'commit #1'" > spam.py
$ git add spam.py
$ git commit -m 'commit msg #1'
[master (root-commit) 1111111] commit msg #1
git commit
$ ls .git/objects/11
11111111111111111111111111111111111111
$ cat .git/refs/heads/master
1111111111111111111111111111111111111111
$ cat .git/HEAD
ref: refs/heads/master
git commit
1111
master
HEAD
top to bottom
5
HEAD
branch
commit
tree
blob
git commit
$ echo "print 'commit #2'" >> spam.py
$ git commit -am 'commit msg #2'
[master 2222222] commit msg #2
$ cat .git/HEAD
ref: refs/heads/master
git commit
1111
master
HEAD2222
git commit
$ git show-ref master --abbrev
2222222 refs/heads/master
$ git cat-file -p 2222 | grep parent
parent 1111111111111111111111111111111111111111
git branch
$ git branch feature_branch
$ ls .git/refs/heads/
feature_branch
master
$ git show-ref --abbrev
2222222 refs/heads/feature_branch
2222222 refs/heads/master
git branch
1111
master
HEAD2222
feature_branch
git checkout
$ cat .git/HEAD
ref: refs/heads/master <- before
$ git checkout feature_branch
$ cat .git/HEAD
ref: refs/heads/feature_branch <- after
git checkout
1111
master
HEAD2222
feature_branch
working on a branch
$ echo "print 'commit #3'" > eggs.py
$ git add eggs.py
$ git commit -m 'commit msg #3'
[feature_branch 3333333] commit msg #3
$ git show-ref --abbrev
3333333 refs/heads/feature_branch
2222222 refs/heads/master
working on a branch
1111
master
HEAD2222
feature_branch
3333
divergence
$ git checkout master
$ echo "print 'commit #4'" > spam.py
$ git commit -am 'commit msg #4'
[master 4444444] commit msg #4
divergence
1111
master
HEAD2222
feature_branch
3333
4444
git merge
$ git merge --no-edit feature_branch
Merge made by the 'recursive' strategy. <- important
eggs.py | 1 +
1 file changed, 1 insertion($)
create mode 100644 eggs.py
git merge
1111
master
HEAD2222
feature_branch
3333
4444
5555
git lol
$ git log --graph --oneline --decorate
* 5555555 (HEAD -> master) Merge branch 'feature_branch'
|
| * 3333333 (feature_branch) commit msg #3
* | 4444444 commit msg #4
|/
* 2222222 commit msg #2
* 1111111 commit msg #1
git merge
$ git show-ref master --abbrev
5555555 refs/heads/master
$ git cat-file -p 5555 | grep parent
parent 4444444444444444444444444444444444444444 <-
master
parent 3333333333333333333333333333333333333333 <- fe.
br.
merge vs. rebase
record of what
actually happened
vs. story of how your
project was made
git reset (to a commit)
change index? change working dir? working dir safe?
git reset --soft SHA Yes No
git reset --mixed SHA No Yes
git reset --hard SHA Yes Yes
git reset
$ git show-ref --abbrev
3333333 refs/heads/feature_branch
5555555 refs/heads/master
$ git reset --hard HEAD^
HEAD is now at 4444444 commit msg #4
$ git show-ref --abbrev
3333333 refs/heads/feature_branch
4444444 refs/heads/master
git reset
1111
master
HEAD2222
3333
4444
5555
feature_branch
feature_branch
git reset, simplified
1111
master
HEAD2222
3333
4444
git rebase
$ git show-ref feature_branch --abbrev
3333333 refs/heads/feature_branch
$ git checkout feature_branch
$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: commit msg #3
$ git show-ref feature_branch --abbrev
6666666 refs/heads/feature_branch
git rebase
1111
master
HEAD2222
feature_branch
3333
4444
6666
git rebase, simplified
1111
master
HEAD2222
feature_branch
4444 6666
git merge - fast forward
$ git checkout master
$ git merge feature_branch
Updating 4444444..6666666
Fast-forward <- important
eggs.py | 1 $
1 file changed, 1 insertion($)
create mode 100644 eggs.py
git merge - fast forward
1111
master
HEAD2222
feature_branch
4444 6666
git merge - fast forward
$ git show-ref --abbrev
6666666 refs/heads/feature_branch
6666666 refs/heads/master
$ ls
eggs.py
spam.py
git reflog
$ git reflog
6666666 HEAD@{0}: merge feature_branch: Fast-forward
...
6666666 HEAD@{3}: rebase: commit msg #3
...
4444444 HEAD@{6}: reset: moving to HEAD^
5555555 HEAD@{7}: merge feature_branch: Merge made by the
'recursive' strategy.
...
git fsck
$ echo "lost?" >> spam.py && git add spam.py
$ echo "no" >> spam.py && git add spam.py
$ git fsck --unreachable
unreachable blob 7777777777777777777777777777777777777777
$ git cat-file -p 7777
print 'commit #4'
lost?
git gc
$ git fsck --unreachable
unreachable blob 7777777777777777777777777777777777777777
$ git gc --prune=all
$ git fsck --unreachable
$ git cat-file -p 7777
fatal: Not a valid object name 7777
detached head state
$ git checkout 5555555
<(HEAD detached at 5555555)> $ cat .git/HEAD
5555555555555555555555555555555555555555
<(HEAD detached at 5555555)> $ # look around, even do work
$ git checkout -b nostalgia
$ git branch
feature_branch
master
* nostalgia
trends

More Related Content

What's hot

Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlBecky Todd
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたTakeshi Arabiki
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)bryanbibat
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginnersbryanbibat
 
Understanding git: Voxxed Vienna 2016
Understanding git: Voxxed Vienna 2016Understanding git: Voxxed Vienna 2016
Understanding git: Voxxed Vienna 2016Steve Smith
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Brian K. Vagnini
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeAcademy
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6brian d foy
 
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshopŁukasz Lalik
 

What's hot (20)

Git the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version controlGit the Docs: A fun, hands-on introduction to version control
Git the Docs: A fun, hands-on introduction to version control
 
Git real slides
Git real slidesGit real slides
Git real slides
 
CouchDB Day NYC 2017: JSON Documents
CouchDB Day NYC 2017: JSON DocumentsCouchDB Day NYC 2017: JSON Documents
CouchDB Day NYC 2017: JSON Documents
 
R版Getopt::Longを作ってみた
R版Getopt::Longを作ってみたR版Getopt::Longを作ってみた
R版Getopt::Longを作ってみた
 
Git Basics (Professionals)
 Git Basics (Professionals) Git Basics (Professionals)
Git Basics (Professionals)
 
簡單介紹git
簡單介紹git簡單介紹git
簡單介紹git
 
Hands on Hadoop
Hands on HadoopHands on Hadoop
Hands on Hadoop
 
Make
MakeMake
Make
 
Version Control with Git for Beginners
Version Control with Git for BeginnersVersion Control with Git for Beginners
Version Control with Git for Beginners
 
CouchDB Day NYC 2017: Mango
CouchDB Day NYC 2017: MangoCouchDB Day NYC 2017: Mango
CouchDB Day NYC 2017: Mango
 
XML for bioinformatics
XML for bioinformaticsXML for bioinformatics
XML for bioinformatics
 
CouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce ViewsCouchDB Day NYC 2017: MapReduce Views
CouchDB Day NYC 2017: MapReduce Views
 
Understanding git: Voxxed Vienna 2016
Understanding git: Voxxed Vienna 2016Understanding git: Voxxed Vienna 2016
Understanding git: Voxxed Vienna 2016
 
Git
GitGit
Git
 
390a gitintro 12au
390a gitintro 12au390a gitintro 12au
390a gitintro 12au
 
Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615Intro to Git DevOps Tally Presentation 101615
Intro to Git DevOps Tally Presentation 101615
 
KubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume PluginsKubeCon EU 2016: Custom Volume Plugins
KubeCon EU 2016: Custom Volume Plugins
 
6 things about perl 6
6 things about perl 66 things about perl 6
6 things about perl 6
 
Git introduction
Git introductionGit introduction
Git introduction
 
Brainly git basics workshop
Brainly git basics workshopBrainly git basics workshop
Brainly git basics workshop
 

Similar to git internals

Similar to git internals (20)

Git and github 101
Git and github 101Git and github 101
Git and github 101
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Git
GitGit
Git
 
Loading...git
Loading...gitLoading...git
Loading...git
 
Git walkthrough
Git walkthroughGit walkthrough
Git walkthrough
 
GIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control SystemGIT: Content-addressable filesystem and Version Control System
GIT: Content-addressable filesystem and Version Control System
 
Git Aliases of the Gods!
Git Aliases of the Gods!Git Aliases of the Gods!
Git Aliases of the Gods!
 
Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
Git
GitGit
Git
 
Git internals
Git internalsGit internals
Git internals
 
Get on with git
Get on with gitGet on with git
Get on with git
 
Essential git fu for tech writers
Essential git fu for tech writersEssential git fu for tech writers
Essential git fu for tech writers
 
Git like a pro EDD18 - Full edition
Git like a pro EDD18 - Full editionGit like a pro EDD18 - Full edition
Git like a pro EDD18 - Full edition
 
GTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSourceGTFO: Git Theory For OpenSource
GTFO: Git Theory For OpenSource
 
Exprimiendo GIT
Exprimiendo GITExprimiendo GIT
Exprimiendo GIT
 
Getting some Git
Getting some GitGetting some Git
Getting some Git
 
T3dd10 git
T3dd10 gitT3dd10 git
T3dd10 git
 
Git - Get Ready To Use It
Git - Get Ready To Use ItGit - Get Ready To Use It
Git - Get Ready To Use It
 
GIT - GOOD PRACTICES
GIT - GOOD PRACTICESGIT - GOOD PRACTICES
GIT - GOOD PRACTICES
 
Gittalk
GittalkGittalk
Gittalk
 

More from Dennis Byrne

Agility - Part 1 of 2
Agility - Part 1 of 2Agility - Part 1 of 2
Agility - Part 1 of 2Dennis Byrne
 
LinkedIn Mobile Search iPhone Architecture
LinkedIn Mobile Search iPhone ArchitectureLinkedIn Mobile Search iPhone Architecture
LinkedIn Mobile Search iPhone ArchitectureDennis Byrne
 
Introduction to Unit Testing (Part 2 of 2)
Introduction to Unit Testing (Part 2 of 2)Introduction to Unit Testing (Part 2 of 2)
Introduction to Unit Testing (Part 2 of 2)Dennis Byrne
 
Introduction to Unit Testing (Part 1 of 2)
Introduction to Unit Testing (Part 1 of 2)Introduction to Unit Testing (Part 1 of 2)
Introduction to Unit Testing (Part 1 of 2)Dennis Byrne
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming LanguageDennis Byrne
 
JavaServer Faces Anti-Patterns and Pitfalls
JavaServer Faces Anti-Patterns and PitfallsJavaServer Faces Anti-Patterns and Pitfalls
JavaServer Faces Anti-Patterns and PitfallsDennis Byrne
 
Integrating Erlang and Java
Integrating Erlang and Java Integrating Erlang and Java
Integrating Erlang and Java Dennis Byrne
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming LanguageDennis Byrne
 

More from Dennis Byrne (10)

Agility - Part 1 of 2
Agility - Part 1 of 2Agility - Part 1 of 2
Agility - Part 1 of 2
 
LinkedIn Mobile Search iPhone Architecture
LinkedIn Mobile Search iPhone ArchitectureLinkedIn Mobile Search iPhone Architecture
LinkedIn Mobile Search iPhone Architecture
 
Introduction to Unit Testing (Part 2 of 2)
Introduction to Unit Testing (Part 2 of 2)Introduction to Unit Testing (Part 2 of 2)
Introduction to Unit Testing (Part 2 of 2)
 
Introduction to Unit Testing (Part 1 of 2)
Introduction to Unit Testing (Part 1 of 2)Introduction to Unit Testing (Part 1 of 2)
Introduction to Unit Testing (Part 1 of 2)
 
Memory Barriers
Memory BarriersMemory Barriers
Memory Barriers
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming Language
 
JavaServer Faces Anti-Patterns and Pitfalls
JavaServer Faces Anti-Patterns and PitfallsJavaServer Faces Anti-Patterns and Pitfalls
JavaServer Faces Anti-Patterns and Pitfalls
 
Integrating Erlang and Java
Integrating Erlang and Java Integrating Erlang and Java
Integrating Erlang and Java
 
The Erlang Programming Language
The Erlang Programming LanguageThe Erlang Programming Language
The Erlang Programming Language
 
DSLs In Erlang
DSLs In ErlangDSLs In Erlang
DSLs In Erlang
 

Recently uploaded

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprisepreethippts
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtimeandrehoraa
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfMarharyta Nedzelska
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineeringssuserb3a23b
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentationvaddepallysandeep122
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...OnePlan Solutions
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfDrew Moseley
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsChristian Birchler
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Matt Ray
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Hr365.us smith
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Mater
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Cizo Technology Services
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesŁukasz Chruściel
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odishasmiwainfosol
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...Technogeeks
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsSafe Software
 

Recently uploaded (20)

Odoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 EnterpriseOdoo 14 - eLearning Module In Odoo 14 Enterprise
Odoo 14 - eLearning Module In Odoo 14 Enterprise
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
SpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at RuntimeSpotFlow: Tracking Method Calls and States at Runtime
SpotFlow: Tracking Method Calls and States at Runtime
 
A healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdfA healthy diet for your Java application Devoxx France.pdf
A healthy diet for your Java application Devoxx France.pdf
 
Software Coding for software engineering
Software Coding for software engineeringSoftware Coding for software engineering
Software Coding for software engineering
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
PREDICTING RIVER WATER QUALITY ppt presentation
PREDICTING  RIVER  WATER QUALITY  ppt presentationPREDICTING  RIVER  WATER QUALITY  ppt presentation
PREDICTING RIVER WATER QUALITY ppt presentation
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
Maximizing Efficiency and Profitability with OnePlan’s Professional Service A...
 
Comparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdfComparing Linux OS Image Update Models - EOSS 2024.pdf
Comparing Linux OS Image Update Models - EOSS 2024.pdf
 
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving CarsSensoDat: Simulation-based Sensor Dataset of Self-driving Cars
SensoDat: Simulation-based Sensor Dataset of Self-driving Cars
 
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
Open Source Summit NA 2024: Open Source Cloud Costs - OpenCost's Impact on En...
 
Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)Recruitment Management Software Benefits (Infographic)
Recruitment Management Software Benefits (Infographic)
 
Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)Ahmed Motair CV April 2024 (Senior SW Developer)
Ahmed Motair CV April 2024 (Senior SW Developer)
 
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
Global Identity Enrolment and Verification Pro Solution - Cizo Technology Ser...
 
Unveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New FeaturesUnveiling the Future: Sylius 2.0 New Features
Unveiling the Future: Sylius 2.0 New Features
 
Advantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your BusinessAdvantages of Odoo ERP 17 for Your Business
Advantages of Odoo ERP 17 for Your Business
 
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company OdishaBalasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
Balasore Best It Company|| Top 10 IT Company || Balasore Software company Odisha
 
What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...What is Advanced Excel and what are some best practices for designing and cre...
What is Advanced Excel and what are some best practices for designing and cre...
 
Powering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data StreamsPowering Real-Time Decisions with Continuous Data Streams
Powering Real-Time Decisions with Continuous Data Streams
 

git internals

  • 2. agenda 1.data ... in two commits a. blobs b. trees c. commits 2.algorithms ... in six commits a. commit b. branch c. merge d. reset
  • 4. objects, blobs $ git init objects_example $ cd objects_example $ echo "puts 'hello world'" > foo.rb $ git add foo.rb $ strings .git/index | grep hello $ strings .git/index | grep foo.rb foo.rb
  • 5. objects, blobs $ find .git/objects -type file .git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa $ git cat-file -t aaaa # what type of object is this? blob $ git cat-file -p aaaa # print the object puts 'hello world'
  • 6. objects, blobs $ echo "puts 'hello world'" > bar.rb $ git add bar.rb $ strings .git/index | grep bar.rb bar.rb $ find .git/objects -type file # no new blob .git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
  • 7. objects $ git commit -m 'commit msg #1' $ find .git/objects -type file .git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa .git/objects/bb/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb .git/objects/cc/cccccccccccccccccccccccccccccccccccccc
  • 8. objects, trees $ git cat-file -t bbbb tree $ git cat-file -p bbbb 100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bar.rb 100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa foo.rb
  • 9. objects, commits $ git cat-file -t cccc commit $ git cat-file -p cccc tree bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb author dbyrne <dennis.byrne@gmail.com> 1474171822 -0700 committer dbyrne <dennis.byrne@gmail.com> 1474171822 -0700 commit msg #1
  • 11. objects $ mkdir dir $ echo "puts 'hello world'" > dir/baz.rb $ git add dir/baz.rb $ git commit -m 'commit msg #2'
  • 12. objects $ find .git/objects -type file .git/objects/aa/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa .git/objects/bb/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb .git/objects/cc/cccccccccccccccccccccccccccccccccccccc .git/objects/dd/dddddddddddddddddddddddddddddddddddddd <- new .git/objects/ee/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee <- new .git/objects/ff/ffffffffffffffffffffffffffffffffffffff <- new
  • 13. objects $ git cat-file -p HEAD^{commit} # same as ffff tree eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee parent cccccccccccccccccccccccccccccccccccccccc author dbyrne <dennis.byrne@gmail.com> 1474172113 -0700 committer dbyrne <dennis.byrne@gmail.com> 1474172113 -0700 commit msg #2
  • 14. objects $ git cat-file -p HEAD^{tree} # same as eeee 100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa bar.rb 040000 tree dddddddddddddddddddddddddddddddddddddddd dir 100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa foo.rb
  • 15. objects $ git cat-file -t dddd tree $ git cat-file -p dddd 100644 blob aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa baz.rb
  • 16. c a b / f e / d /dir foo.rb bar.rb baz.rb foo.rb bar.rb
  • 17. objects there are three types of objects: blobs, trees & commits blobs represent files blobs are created with the add, not the commit command blobs are snapshots, not deltas or patches the add command records snapshots every time a file can be both “staged” and “modified” trees represent directories trees point to blobs and/or trees
  • 18. refs $ ls .git/HEAD .git/HEAD <- important $ tree .git/refs/ ├── heads <- important │ └── master ├── remotes ├── stash └── tags
  • 19. git commit $ git init refs_example $ cd refs_example $ echo "print 'commit #1'" > spam.py $ git add spam.py $ git commit -m 'commit msg #1' [master (root-commit) 1111111] commit msg #1
  • 20. git commit $ ls .git/objects/11 11111111111111111111111111111111111111 $ cat .git/refs/heads/master 1111111111111111111111111111111111111111 $ cat .git/HEAD ref: refs/heads/master
  • 23. git commit $ echo "print 'commit #2'" >> spam.py $ git commit -am 'commit msg #2' [master 2222222] commit msg #2 $ cat .git/HEAD ref: refs/heads/master
  • 25. git commit $ git show-ref master --abbrev 2222222 refs/heads/master $ git cat-file -p 2222 | grep parent parent 1111111111111111111111111111111111111111
  • 26. git branch $ git branch feature_branch $ ls .git/refs/heads/ feature_branch master $ git show-ref --abbrev 2222222 refs/heads/feature_branch 2222222 refs/heads/master
  • 28. git checkout $ cat .git/HEAD ref: refs/heads/master <- before $ git checkout feature_branch $ cat .git/HEAD ref: refs/heads/feature_branch <- after
  • 30. working on a branch $ echo "print 'commit #3'" > eggs.py $ git add eggs.py $ git commit -m 'commit msg #3' [feature_branch 3333333] commit msg #3 $ git show-ref --abbrev 3333333 refs/heads/feature_branch 2222222 refs/heads/master
  • 31. working on a branch 1111 master HEAD2222 feature_branch 3333
  • 32. divergence $ git checkout master $ echo "print 'commit #4'" > spam.py $ git commit -am 'commit msg #4' [master 4444444] commit msg #4
  • 34. git merge $ git merge --no-edit feature_branch Merge made by the 'recursive' strategy. <- important eggs.py | 1 + 1 file changed, 1 insertion($) create mode 100644 eggs.py
  • 36. git lol $ git log --graph --oneline --decorate * 5555555 (HEAD -> master) Merge branch 'feature_branch' | | * 3333333 (feature_branch) commit msg #3 * | 4444444 commit msg #4 |/ * 2222222 commit msg #2 * 1111111 commit msg #1
  • 37. git merge $ git show-ref master --abbrev 5555555 refs/heads/master $ git cat-file -p 5555 | grep parent parent 4444444444444444444444444444444444444444 <- master parent 3333333333333333333333333333333333333333 <- fe. br.
  • 38. merge vs. rebase record of what actually happened vs. story of how your project was made
  • 39. git reset (to a commit) change index? change working dir? working dir safe? git reset --soft SHA Yes No git reset --mixed SHA No Yes git reset --hard SHA Yes Yes
  • 40. git reset $ git show-ref --abbrev 3333333 refs/heads/feature_branch 5555555 refs/heads/master $ git reset --hard HEAD^ HEAD is now at 4444444 commit msg #4 $ git show-ref --abbrev 3333333 refs/heads/feature_branch 4444444 refs/heads/master
  • 43. git rebase $ git show-ref feature_branch --abbrev 3333333 refs/heads/feature_branch $ git checkout feature_branch $ git rebase master First, rewinding head to replay your work on top of it... Applying: commit msg #3 $ git show-ref feature_branch --abbrev 6666666 refs/heads/feature_branch
  • 46. git merge - fast forward $ git checkout master $ git merge feature_branch Updating 4444444..6666666 Fast-forward <- important eggs.py | 1 $ 1 file changed, 1 insertion($) create mode 100644 eggs.py
  • 47. git merge - fast forward 1111 master HEAD2222 feature_branch 4444 6666
  • 48. git merge - fast forward $ git show-ref --abbrev 6666666 refs/heads/feature_branch 6666666 refs/heads/master $ ls eggs.py spam.py
  • 49. git reflog $ git reflog 6666666 HEAD@{0}: merge feature_branch: Fast-forward ... 6666666 HEAD@{3}: rebase: commit msg #3 ... 4444444 HEAD@{6}: reset: moving to HEAD^ 5555555 HEAD@{7}: merge feature_branch: Merge made by the 'recursive' strategy. ...
  • 50. git fsck $ echo "lost?" >> spam.py && git add spam.py $ echo "no" >> spam.py && git add spam.py $ git fsck --unreachable unreachable blob 7777777777777777777777777777777777777777 $ git cat-file -p 7777 print 'commit #4' lost?
  • 51. git gc $ git fsck --unreachable unreachable blob 7777777777777777777777777777777777777777 $ git gc --prune=all $ git fsck --unreachable $ git cat-file -p 7777 fatal: Not a valid object name 7777
  • 52. detached head state $ git checkout 5555555 <(HEAD detached at 5555555)> $ cat .git/HEAD 5555555555555555555555555555555555555555 <(HEAD detached at 5555555)> $ # look around, even do work $ git checkout -b nostalgia $ git branch feature_branch master * nostalgia