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 (18)

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
 
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
 
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

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is insideshinachiaurasa2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...masabamasaba
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...Jittipong Loespradit
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024VictoriaMetrics
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 

Recently uploaded (20)

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
The title is not connected to what is inside
The title is not connected to what is insideThe title is not connected to what is inside
The title is not connected to what is inside
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
Large-scale Logging Made Easy: Meetup at Deutsche Bank 2024
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 

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