SlideShare a Scribd company logo
1 of 28
Git Internals
Haggai Philip Zagury,
Q1 2013 @:
whoami
Haggai Philip Zagury
CM / DevOps Engineer
Over 5 years of CM/ALM/DevOps
expertise
“I am a member of Tikal's ALM group.
With over 12 members, we meet, share,
contribute and code together on a bi-weekly
basis. “
Inspired by Scott ChaconAuthor of "Pro Git"
Whilst lecturing about
git / Introducing git.
I got the impression
that without git
internals some
concepts of git were
unclear - thus I created
this set of slides
Git's internals
~/Projects/git/git_intro/(master) $> git commit -m
"Adding README file"
[master (root-commit) 38a5307] Adding README file
1 file changed, 2 insertions(+)
create mode 100644 README
The ${GIT_DIR} .git directory
Before the commit:
~/Projects/git/git_intro/(master) $> find .git
.git
.git/refs
.git/refs/heads
.git/refs/tags
.git/description
.git/hooks/...
.git/config
.git/info
.git/info/exclude
.git/branches
.git/objects
.git/objects/pack
.git/objects/info
.git/HEAD
~/Projects/git/git_intro/(master) $> find .git
.git
.git/COMMIT_EDITMSG
.git/refs
.git/refs/heads
.git/refs/heads/master
.git/refs/tags
.git/description
.git/hooks/...
.git/index
.git/config
.git/info
.git/info/exclude
.git/branches
.git/objects
.git/objects/bd
.git/objects/bd/2510ea0000fa2294947172f6f450bd0272fdab
.git/objects/38
.git/objects/38/a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
.git/objects/pack
.git/objects/info
.git/objects/43
.git/objects/43/841a2f87570c9e458ab1da83396e0a5563ff36
.git/logs
.git/logs/refs
.git/logs/refs/heads
.git/logs/refs/heads/master
.git/logs/HEAD
.git/HEAD
After the commit:
What happened ? Git Objects
Every commit consists
of objects of three types:
[ To be precise the tree & blob are created when you
add/stage the commit is created when you -> commit
], more about that in a few ...
commit -> a snapshot in time
tree -> represent directory
blob -> file content
DAG - Directed acyclic graph
Git uses DAG and a
hash mechanism to
redirect / map the
repository.
A directed acyclic graph (DAG
i
/ˈdæɡ/), is a directed graph with no directed
cycles. That is, it is formed by a collection of
vertices and directed edges, each edge
connecting one vertex to another, such that
there is no way to start at some vertex v and
follow a sequence of edges that eventually
loops back to v again.
Our README as object(s)
git log ->
commit 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
Author: Haggai Philip Zagury <hagzag@tikalk.com>
Date: Sat Apr 20 18:27:02 2013 +0300
commit ->
tree 43841a2f87570c9e458ab1da83396e0a5563ff36
author Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300
committer Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300
Tree ->
100644 blob bd2510ea0000fa2294947172f6f450bd0272fdab README
Blob ->
=== README FILE for git_intro ===
Version 1.0
8a7534e5
43841a2f
bd2510ea
refs [references]
8a7534e5
43841a2f
bd2510ea
point to subdir /
file name & mode
pointer to parent
commit
master
HEAD*
$> find .git/refs/
.git/refs/
.git/refs/heads
.git/refs/heads/master
.git/refs/tags
$> cat .git/refs/heads/master
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
The "master" branch is just like a "post-it"
reference to the SHA1 of the latest commit
Probing Git Objects
C1 README
C2 hello.rb
$> git cat-file -p 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
tree 43841a2f87570c9e458ab1da83396e0a5563ff36
author Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300
committer Haggai Philip Zagury <hagzag@tikalk.com> 1366471622
+0300
Adding README fileparent
git log http://git-scm.com/docs/git-log
In every repository there is at least one "parent-less" commit
$> git cat-file -p 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
tree ea94fb0f34ca7dbcfc6ecaf7077dfe4b12725068
parent 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
author Haggai Philip Zagury <hagzag@tikalk.com> 1366488967 +0300
committer Haggai Philip Zagury <hagzag@tikalk.com> 1366488967
+0300
Adding hello.rb to repo
The commands are presented for
educational purposes and are rarely
used by the common developer ...
It's a blob more probing...
Git stores a single file per piece of content, named with the SHA-1 checksum of the content and its header.
The subdirectory is named with the first 2 characters of the SHA, and the filename is the remaining 38
characters
$> git log
commit 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
Author: Haggai Philip Zagury <hagzag@tikalk.com>
Date: Sat Apr 20 23:16:07 2013 +0300
Adding hello.rb to repo
$> git cat-file -t 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
commit
$> git cat-file -t bd2510ea0000fa2294947172f6f450bd0272fdab
blob
$> find .git/objects/ -type f
.
git/objects/bd/2510ea0000fa2294947172f6f450bd0272fda
b
.git/objects/5e/b56f99ad91c6e8933c3e06593a66a09e3a1b91
.git/objects/38/a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
.git/objects/ea/94fb0f34ca7dbcfc6ecaf7077dfe4b12725068
.git/objects/43/841a2f87570c9e458ab1da83396e0a5563ff36
.git/objects/8a/7534e5ac1eb36ef21b8c4a06b8af5d59abee50
bd + 2510ea0000fa2294947172f6f450bd0272fdab = README
$> git cat-file -p bd2510ea0000fa2294947172f6f450bd0272fdab
=== README FILE for git_into ===
Version 1.0
Branching & tagging
We already know branches :)
master == branch
refs [references]
8a7534e5
43841a2f
bd2510ea
point to subdir /
file name & mode
pointer to parent
commit
master
HEAD*
$> find .git/refs/
.git/refs/
.git/refs/heads
.git/refs/heads/master
.git/refs/tags
$> cat .git/refs/heads/master
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
The "master" branch is just like a "post-it"
reference to the SHA1 of the latest commit
refs [references]
8a7534e5
43841a2f
bd2510ea
point to subdir /
file name & mode
pointer to parent
commit
foo
HEAD*
$> find .git/refs/
.git/refs/
.git/refs/heads
.git/refs/heads/master
.git/refs/tags
$> cat .git/refs/heads/master
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
The "master" branch is just like a "post-it"
reference to the SHA1 of the latest commit
Context based development
git branch http://git-scm.com/docs/git-branch
$> git checkout -b second-idea
will switch and create a new branch in that name in one
command [ like executing:
"git branch the-idea && git checkcout the-idea" ]
$> git branch
* master
$> git branch the-idea
$> git branch
* master
the-idea
$> git checkout the-idea
Switched to branch 'the-idea'
$> ls .git/refs/heads/
master the-idea
refs [references] - branches
8a7534e5
43841a2f
bd2510ea
point to subdir /
file name & mode
pointer to parent
commit
master
HEAD*
the-idea
$> cat .git/refs/heads/master
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
$> cat .git/refs/heads/the-idea
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
$> as long as I haven't added anything to the new
branch, the pointer's content is on the same commit
as "master" branch - Remember DAG ?!
$> git checkout the-idea
Switched to branch 'the-idea'
refs change
$> sed -i s/1.0/2.0/g README
$> git commit -a -m "Bumping version to 2.0"
[the-idea aedd0cd] Bumping version to 2.0
1 file changed, 1 insertion(+), 1 deletion(-)
$> cat .git/refs/heads/master .git/refs/heads/the-idea
8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50
aedd0cd8ba404f292bdf3f9542d67285c489a143
$>The reference to the new object has changed the
parent object [DAG ...] is the same
8a7534e5
master
HEAD*
the-idea
aedd0cd8
Deleting branches
All that was removed is the reference to the node in the graph
so basically we can recreate that bench to that point in time
[SHA1 aedd0cd8] any time we want !
$> git branch -d the-idea
error: Cannot delete the branch 'the-idea' which you are currently on.
$> git checkout master
Switched to branch 'master'
$> git branch -d the-idea
error: The branch 'the-idea' is not fully merged.
If you are sure you want to delete it, run 'git branch -D the-idea'.
8a7534e5
master
HEAD*
the-idea
aedd0cd8
Let's create a conflict (on master)
8a7534e5
aedd0cd8
master
HEAD*
the-idea
1706dbd
$> sed -i s/1.0/1.1/g README
$> git commit -a -m "This change will create a conflict whilst
merging "the-idea" branch"
[master 1706dbd] This change will create a conflict whilst merging
"the-idea" branch
1 file changed, 1 insertion(+), 1 deletion(-)
$> git log --oneline --graph --decorate --all
* 1706dbd (master) This change will create a conflict whilst merging "the-idea" branch
| * aedd0cd (HEAD, the-idea) Bumping version to 2.0
| /
* 8a7534e (second-idea) Adding hello.rb to repo
* 38a5307 Adding README file
"Visualize it"
gitk - viewing changes ...
Available with git extensions & others | equivalent
$> gitk --all
Tagging
Wait, I need to tag the version 1.0 ...
And no, a TAG isn't a BRANCH !
Tag is an object in the DAG + commit
message & optional gpg signature
8a7534e5
aedd0cd8
master
HEAD*
the-idea
1706dbd
1.0
2.0
1.1
$> git tag -a v1.0 -m 'version 1.0' 8a7534e5
$> git show v1.0
tag v1.0
Tagger: Haggai Philip Zagury <hagzag@tikalk.com>
Date: Wed Apr 24 01:24:03 2013 +0300
verion 1.0
commit 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3
git tag http://git-scm.com/docs/git-tag
git tag foo - will create a tag named foo to the
current HEAD reference
Merging with Git
Merging
Integrating two nodes in the DAG - that's all it is ...
$> git log --pretty=oneline --graph --decorate --all
* 3bd95903b3e2a3934b1d3bc1495f7c5c9ced5df2 (HEAD, master) Merge branch 'the-idea'
|
| * aedd0cd8ba404f292bdf3f9542d67285c489a143 (the-idea) Bumping version to 2.0
* | 1706dbd411de152c462172386eafa238fc50f50b This change ... conflict ... merging "the-idea" branch
|/
* 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 (second-idea) Adding hello.rb to repo
* 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 Adding README file
$> git log
commit 3bd95903b3e2a3934b1d3bc1495f7c5c9ced5df2
Merge: 1706dbd aedd0cd
Author: Haggai Philip Zagury <hagzag@tikalk.com>
Date: Tue Apr 23 22:34:54 2013 +0300
Merge branch 'the-idea'
Conflicts:
README
Non/Fast Forward
8a7534e5
master
the-idea
aedd0cd8
ae2c0cd8
9idb9cd8
8a7534e5
master
the-idea
aedd0cd8
ae2c0cd8
9idb9cd8
8a7534e5
master the-idea
aedd0cd8
as34cd8
9idb9cd8
ae2c0cd8
Fast Forward Non Fast ForwardBefore merge
Remote Tracking
Remote tracking Reference(s)
The remote/master is the
same type of reference like the
"local" master but from a
different namespace.
.git/refs/remotes/...
This namespace is mapped
to the remote server !
- represented by a url
8a7534e5
43841a2f
bd2510ea
master
HEAD*
remotes/server/master
Git internals

More Related Content

What's hot

What's hot (20)

Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
 
Git inter-snapshot public
Git  inter-snapshot publicGit  inter-snapshot public
Git inter-snapshot public
 
Git - a powerful version control tool
Git - a powerful version control toolGit - a powerful version control tool
Git - a powerful version control tool
 
Github - Git Training Slides: Foundations
Github - Git Training Slides: FoundationsGithub - Git Training Slides: Foundations
Github - Git Training Slides: Foundations
 
Git & GitHub for Beginners
Git & GitHub for BeginnersGit & GitHub for Beginners
Git & GitHub for Beginners
 
Did you git yet?
Did you git yet?Did you git yet?
Did you git yet?
 
Advanced Git Tutorial
Advanced Git TutorialAdvanced Git Tutorial
Advanced Git Tutorial
 
Git and Github
Git and GithubGit and Github
Git and Github
 
Git training
Git trainingGit training
Git training
 
Git tutorial
Git tutorialGit tutorial
Git tutorial
 
Starting with Git & GitHub
Starting with Git & GitHubStarting with Git & GitHub
Starting with Git & GitHub
 
Git and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern DeveloperGit and github - Verson Control for the Modern Developer
Git and github - Verson Control for the Modern Developer
 
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
Nicola Iarocci - Git stories from the front line - Codemotion Milan 2017
 
Bitbucket
BitbucketBitbucket
Bitbucket
 
Inside GitHub with Chris Wanstrath
Inside GitHub with Chris WanstrathInside GitHub with Chris Wanstrath
Inside GitHub with Chris Wanstrath
 
Git Tutorial I
Git Tutorial IGit Tutorial I
Git Tutorial I
 
Presentacion git
Presentacion gitPresentacion git
Presentacion git
 
Git Basics - RubyFest 2009
Git Basics - RubyFest 2009Git Basics - RubyFest 2009
Git Basics - RubyFest 2009
 
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
What is Git | What is GitHub | Git Tutorial | GitHub Tutorial | Devops Tutori...
 
Introduction to Git / Github
Introduction to Git / GithubIntroduction to Git / Github
Introduction to Git / Github
 

Viewers also liked

Serving management scenario v1
Serving management scenario v1Serving management scenario v1
Serving management scenario v1
David Sterrett
 
Uspto reexamination request - update - mar 09 to mar 15, 2011 - invn tree
Uspto   reexamination request - update - mar 09 to mar 15, 2011 - invn treeUspto   reexamination request - update - mar 09 to mar 15, 2011 - invn tree
Uspto reexamination request - update - mar 09 to mar 15, 2011 - invn tree
InvnTree IP Services Pvt. Ltd.
 
Comets presentation
Comets presentationComets presentation
Comets presentation
helllena
 
Her İle Bir Üniversite Politikası
Her İle Bir Üniversite PolitikasıHer İle Bir Üniversite Politikası
Her İle Bir Üniversite Politikası
Yağmur Kaya
 

Viewers also liked (16)

Serving management scenario v1
Serving management scenario v1Serving management scenario v1
Serving management scenario v1
 
Will going to
Will going toWill going to
Will going to
 
Screen printing on tees in miami
Screen printing on tees in miamiScreen printing on tees in miami
Screen printing on tees in miami
 
Uspto reexamination request - update - mar 09 to mar 15, 2011 - invn tree
Uspto   reexamination request - update - mar 09 to mar 15, 2011 - invn treeUspto   reexamination request - update - mar 09 to mar 15, 2011 - invn tree
Uspto reexamination request - update - mar 09 to mar 15, 2011 - invn tree
 
Prepaid Vs Post-paid Energy
Prepaid Vs Post-paid EnergyPrepaid Vs Post-paid Energy
Prepaid Vs Post-paid Energy
 
17 TIPS TO KEEP IN MIND WHEN IT COMES TO BUSINESS
17 TIPS TO KEEP IN MIND WHEN IT COMES TO BUSINESS17 TIPS TO KEEP IN MIND WHEN IT COMES TO BUSINESS
17 TIPS TO KEEP IN MIND WHEN IT COMES TO BUSINESS
 
Case of contraflow in global media
Case of contraflow in global mediaCase of contraflow in global media
Case of contraflow in global media
 
Balancing Act
Balancing ActBalancing Act
Balancing Act
 
Vento spirito fantasma
Vento spirito fantasmaVento spirito fantasma
Vento spirito fantasma
 
The History of the Horror Genre
The History of the Horror GenreThe History of the Horror Genre
The History of the Horror Genre
 
Comets presentation
Comets presentationComets presentation
Comets presentation
 
Mobile growth demands more from content - Future Female Seminar
Mobile growth demands more from content - Future Female SeminarMobile growth demands more from content - Future Female Seminar
Mobile growth demands more from content - Future Female Seminar
 
Presentació AENTEG
Presentació AENTEGPresentació AENTEG
Presentació AENTEG
 
2.1. Col. Jeffrey Yarvis - Reintegrating Returning Warriors
2.1. Col. Jeffrey Yarvis - Reintegrating Returning Warriors2.1. Col. Jeffrey Yarvis - Reintegrating Returning Warriors
2.1. Col. Jeffrey Yarvis - Reintegrating Returning Warriors
 
Newspaper analysis
Newspaper analysisNewspaper analysis
Newspaper analysis
 
Her İle Bir Üniversite Politikası
Her İle Bir Üniversite PolitikasıHer İle Bir Üniversite Politikası
Her İle Bir Üniversite Politikası
 

Similar to Git internals

Similar to Git internals (20)

Introducción a git y GitHub
Introducción a git y GitHubIntroducción a git y GitHub
Introducción a git y GitHub
 
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
 
Gittalk
GittalkGittalk
Gittalk
 
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 and github 101
Git and github 101Git and github 101
Git and github 101
 
Git Acquainted
Git AcquaintedGit Acquainted
Git Acquainted
 
Git
GitGit
Git
 
Git Concepts, Commands and Connectivity
Git Concepts, Commands and ConnectivityGit Concepts, Commands and Connectivity
Git Concepts, Commands and Connectivity
 
Git
GitGit
Git
 
git - the basics
git - the basicsgit - the basics
git - the basics
 
Pro git - grasping it conceptually
Pro git - grasping it conceptuallyPro git - grasping it conceptually
Pro git - grasping it conceptually
 
Git cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdfGit cheat sheet with diagram-5.pdf
Git cheat sheet with diagram-5.pdf
 
git command
git commandgit command
git command
 
Git-ing out of your git messes - Fluent Conf 2017
Git-ing out of  your git messes - Fluent Conf 2017Git-ing out of  your git messes - Fluent Conf 2017
Git-ing out of your git messes - Fluent Conf 2017
 
Git
GitGit
Git
 
git. WTF is it doing anyway?
git. WTF is it doing anyway?git. WTF is it doing anyway?
git. WTF is it doing anyway?
 
Git Tutorial Yang Yang
Git Tutorial Yang YangGit Tutorial Yang Yang
Git Tutorial Yang Yang
 
Version Control & Git
Version Control & GitVersion Control & Git
Version Control & Git
 
Git basic
Git basicGit basic
Git basic
 
Learning Basic GIT Cmd
Learning Basic GIT CmdLearning Basic GIT Cmd
Learning Basic GIT Cmd
 

More from Haggai Philip Zagury

More from Haggai Philip Zagury (20)

DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
DevOpsDays Tel Aviv DEC 2022 | Building A Cloud-Native Platform Brick by Bric...
 
Kube Security Shifting left | Scanners & OPA
Kube Security Shifting left | Scanners & OPAKube Security Shifting left | Scanners & OPA
Kube Security Shifting left | Scanners & OPA
 
TechRadarCon 2022 | Have you built your platform yet ?
TechRadarCon 2022 | Have you built your platform yet ?TechRadarCon 2022 | Have you built your platform yet ?
TechRadarCon 2022 | Have you built your platform yet ?
 
Gitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCDGitlab, GitOps & ArgoCD
Gitlab, GitOps & ArgoCD
 
DevEx | there’s no place like k3s
DevEx | there’s no place like k3sDevEx | there’s no place like k3s
DevEx | there’s no place like k3s
 
Git ops & Continuous Infrastructure with terra*
Git ops  & Continuous Infrastructure with terra*Git ops  & Continuous Infrastructure with terra*
Git ops & Continuous Infrastructure with terra*
 
Auth experience - vol 1.0
Auth experience  - vol 1.0Auth experience  - vol 1.0
Auth experience - vol 1.0
 
Linux intro
Linux introLinux intro
Linux intro
 
Auth experience
Auth experienceAuth experience
Auth experience
 
Kubexperience intro session
Kubexperience intro sessionKubexperience intro session
Kubexperience intro session
 
Scaling i/o bound Microservices
Scaling i/o bound MicroservicesScaling i/o bound Microservices
Scaling i/o bound Microservices
 
The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2The 2nd half. Scaling to the next^2
The 2nd half. Scaling to the next^2
 
Terraform 101
Terraform 101Terraform 101
Terraform 101
 
Chaos is a ladder !
Chaos is a ladder !Chaos is a ladder !
Chaos is a ladder !
 
Natively clouded Journey
Natively clouded JourneyNatively clouded Journey
Natively clouded Journey
 
Deep Learning - Continuous Operations
Deep Learning - Continuous Operations Deep Learning - Continuous Operations
Deep Learning - Continuous Operations
 
Terraform 101
Terraform 101Terraform 101
Terraform 101
 
Helm intro
Helm introHelm intro
Helm intro
 
Machine Learning - Continuous operations
Machine Learning - Continuous operationsMachine Learning - Continuous operations
Machine Learning - Continuous operations
 
Whats all the FaaS About
Whats all the FaaS AboutWhats all the FaaS About
Whats all the FaaS About
 

Recently uploaded

Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
UXDXConf
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Peter Udo Diehl
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
UK Journal
 

Recently uploaded (20)

Microsoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - QuestionnaireMicrosoft CSP Briefing Pre-Engagement - Questionnaire
Microsoft CSP Briefing Pre-Engagement - Questionnaire
 
Using IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & IrelandUsing IESVE for Room Loads Analysis - UK & Ireland
Using IESVE for Room Loads Analysis - UK & Ireland
 
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
Integrating Telephony Systems with Salesforce: Insights and Considerations, B...
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Structuring Teams and Portfolios for Success
Structuring Teams and Portfolios for SuccessStructuring Teams and Portfolios for Success
Structuring Teams and Portfolios for Success
 
Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024Extensible Python: Robustness through Addition - PyCon 2024
Extensible Python: Robustness through Addition - PyCon 2024
 
A Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System StrategyA Business-Centric Approach to Design System Strategy
A Business-Centric Approach to Design System Strategy
 
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo DiehlFuture Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
Future Visions: Predictions to Guide and Time Tech Innovation, Peter Udo Diehl
 
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
Secure Zero Touch enabled Edge compute with Dell NativeEdge via FDO _ Brad at...
 
Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024Enterprise Knowledge Graphs - Data Summit 2024
Enterprise Knowledge Graphs - Data Summit 2024
 
Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptxWSO2CONMay2024OpenSourceConferenceDebrief.pptx
WSO2CONMay2024OpenSourceConferenceDebrief.pptx
 
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
Choosing the Right FDO Deployment Model for Your Application _ Geoffrey at In...
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdfBreaking Down the Flutterwave Scandal What You Need to Know.pdf
Breaking Down the Flutterwave Scandal What You Need to Know.pdf
 
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdfIntroduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
Introduction to FDO and How It works Applications _ Richard at FIDO Alliance.pdf
 

Git internals

  • 1. Git Internals Haggai Philip Zagury, Q1 2013 @:
  • 2. whoami Haggai Philip Zagury CM / DevOps Engineer Over 5 years of CM/ALM/DevOps expertise “I am a member of Tikal's ALM group. With over 12 members, we meet, share, contribute and code together on a bi-weekly basis. “
  • 3. Inspired by Scott ChaconAuthor of "Pro Git" Whilst lecturing about git / Introducing git. I got the impression that without git internals some concepts of git were unclear - thus I created this set of slides
  • 5. ~/Projects/git/git_intro/(master) $> git commit -m "Adding README file" [master (root-commit) 38a5307] Adding README file 1 file changed, 2 insertions(+) create mode 100644 README The ${GIT_DIR} .git directory Before the commit: ~/Projects/git/git_intro/(master) $> find .git .git .git/refs .git/refs/heads .git/refs/tags .git/description .git/hooks/... .git/config .git/info .git/info/exclude .git/branches .git/objects .git/objects/pack .git/objects/info .git/HEAD ~/Projects/git/git_intro/(master) $> find .git .git .git/COMMIT_EDITMSG .git/refs .git/refs/heads .git/refs/heads/master .git/refs/tags .git/description .git/hooks/... .git/index .git/config .git/info .git/info/exclude .git/branches .git/objects .git/objects/bd .git/objects/bd/2510ea0000fa2294947172f6f450bd0272fdab .git/objects/38 .git/objects/38/a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 .git/objects/pack .git/objects/info .git/objects/43 .git/objects/43/841a2f87570c9e458ab1da83396e0a5563ff36 .git/logs .git/logs/refs .git/logs/refs/heads .git/logs/refs/heads/master .git/logs/HEAD .git/HEAD After the commit:
  • 6. What happened ? Git Objects Every commit consists of objects of three types: [ To be precise the tree & blob are created when you add/stage the commit is created when you -> commit ], more about that in a few ... commit -> a snapshot in time tree -> represent directory blob -> file content
  • 7. DAG - Directed acyclic graph Git uses DAG and a hash mechanism to redirect / map the repository. A directed acyclic graph (DAG i /ˈdæɡ/), is a directed graph with no directed cycles. That is, it is formed by a collection of vertices and directed edges, each edge connecting one vertex to another, such that there is no way to start at some vertex v and follow a sequence of edges that eventually loops back to v again.
  • 8. Our README as object(s) git log -> commit 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 Author: Haggai Philip Zagury <hagzag@tikalk.com> Date: Sat Apr 20 18:27:02 2013 +0300 commit -> tree 43841a2f87570c9e458ab1da83396e0a5563ff36 author Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300 committer Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300 Tree -> 100644 blob bd2510ea0000fa2294947172f6f450bd0272fdab README Blob -> === README FILE for git_intro === Version 1.0 8a7534e5 43841a2f bd2510ea
  • 9. refs [references] 8a7534e5 43841a2f bd2510ea point to subdir / file name & mode pointer to parent commit master HEAD* $> find .git/refs/ .git/refs/ .git/refs/heads .git/refs/heads/master .git/refs/tags $> cat .git/refs/heads/master 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 The "master" branch is just like a "post-it" reference to the SHA1 of the latest commit
  • 10. Probing Git Objects C1 README C2 hello.rb $> git cat-file -p 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 tree 43841a2f87570c9e458ab1da83396e0a5563ff36 author Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300 committer Haggai Philip Zagury <hagzag@tikalk.com> 1366471622 +0300 Adding README fileparent git log http://git-scm.com/docs/git-log In every repository there is at least one "parent-less" commit $> git cat-file -p 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 tree ea94fb0f34ca7dbcfc6ecaf7077dfe4b12725068 parent 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 author Haggai Philip Zagury <hagzag@tikalk.com> 1366488967 +0300 committer Haggai Philip Zagury <hagzag@tikalk.com> 1366488967 +0300 Adding hello.rb to repo The commands are presented for educational purposes and are rarely used by the common developer ...
  • 11. It's a blob more probing... Git stores a single file per piece of content, named with the SHA-1 checksum of the content and its header. The subdirectory is named with the first 2 characters of the SHA, and the filename is the remaining 38 characters $> git log commit 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 Author: Haggai Philip Zagury <hagzag@tikalk.com> Date: Sat Apr 20 23:16:07 2013 +0300 Adding hello.rb to repo $> git cat-file -t 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 commit $> git cat-file -t bd2510ea0000fa2294947172f6f450bd0272fdab blob $> find .git/objects/ -type f . git/objects/bd/2510ea0000fa2294947172f6f450bd0272fda b .git/objects/5e/b56f99ad91c6e8933c3e06593a66a09e3a1b91 .git/objects/38/a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 .git/objects/ea/94fb0f34ca7dbcfc6ecaf7077dfe4b12725068 .git/objects/43/841a2f87570c9e458ab1da83396e0a5563ff36 .git/objects/8a/7534e5ac1eb36ef21b8c4a06b8af5d59abee50 bd + 2510ea0000fa2294947172f6f450bd0272fdab = README $> git cat-file -p bd2510ea0000fa2294947172f6f450bd0272fdab === README FILE for git_into === Version 1.0
  • 13. We already know branches :) master == branch
  • 14. refs [references] 8a7534e5 43841a2f bd2510ea point to subdir / file name & mode pointer to parent commit master HEAD* $> find .git/refs/ .git/refs/ .git/refs/heads .git/refs/heads/master .git/refs/tags $> cat .git/refs/heads/master 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 The "master" branch is just like a "post-it" reference to the SHA1 of the latest commit
  • 15. refs [references] 8a7534e5 43841a2f bd2510ea point to subdir / file name & mode pointer to parent commit foo HEAD* $> find .git/refs/ .git/refs/ .git/refs/heads .git/refs/heads/master .git/refs/tags $> cat .git/refs/heads/master 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 The "master" branch is just like a "post-it" reference to the SHA1 of the latest commit
  • 16. Context based development git branch http://git-scm.com/docs/git-branch $> git checkout -b second-idea will switch and create a new branch in that name in one command [ like executing: "git branch the-idea && git checkcout the-idea" ] $> git branch * master $> git branch the-idea $> git branch * master the-idea $> git checkout the-idea Switched to branch 'the-idea' $> ls .git/refs/heads/ master the-idea
  • 17. refs [references] - branches 8a7534e5 43841a2f bd2510ea point to subdir / file name & mode pointer to parent commit master HEAD* the-idea $> cat .git/refs/heads/master 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 $> cat .git/refs/heads/the-idea 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 $> as long as I haven't added anything to the new branch, the pointer's content is on the same commit as "master" branch - Remember DAG ?! $> git checkout the-idea Switched to branch 'the-idea'
  • 18. refs change $> sed -i s/1.0/2.0/g README $> git commit -a -m "Bumping version to 2.0" [the-idea aedd0cd] Bumping version to 2.0 1 file changed, 1 insertion(+), 1 deletion(-) $> cat .git/refs/heads/master .git/refs/heads/the-idea 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 aedd0cd8ba404f292bdf3f9542d67285c489a143 $>The reference to the new object has changed the parent object [DAG ...] is the same 8a7534e5 master HEAD* the-idea aedd0cd8
  • 19. Deleting branches All that was removed is the reference to the node in the graph so basically we can recreate that bench to that point in time [SHA1 aedd0cd8] any time we want ! $> git branch -d the-idea error: Cannot delete the branch 'the-idea' which you are currently on. $> git checkout master Switched to branch 'master' $> git branch -d the-idea error: The branch 'the-idea' is not fully merged. If you are sure you want to delete it, run 'git branch -D the-idea'. 8a7534e5 master HEAD* the-idea aedd0cd8
  • 20. Let's create a conflict (on master) 8a7534e5 aedd0cd8 master HEAD* the-idea 1706dbd $> sed -i s/1.0/1.1/g README $> git commit -a -m "This change will create a conflict whilst merging "the-idea" branch" [master 1706dbd] This change will create a conflict whilst merging "the-idea" branch 1 file changed, 1 insertion(+), 1 deletion(-) $> git log --oneline --graph --decorate --all * 1706dbd (master) This change will create a conflict whilst merging "the-idea" branch | * aedd0cd (HEAD, the-idea) Bumping version to 2.0 | / * 8a7534e (second-idea) Adding hello.rb to repo * 38a5307 Adding README file "Visualize it"
  • 21. gitk - viewing changes ... Available with git extensions & others | equivalent $> gitk --all
  • 22. Tagging Wait, I need to tag the version 1.0 ... And no, a TAG isn't a BRANCH ! Tag is an object in the DAG + commit message & optional gpg signature 8a7534e5 aedd0cd8 master HEAD* the-idea 1706dbd 1.0 2.0 1.1 $> git tag -a v1.0 -m 'version 1.0' 8a7534e5 $> git show v1.0 tag v1.0 Tagger: Haggai Philip Zagury <hagzag@tikalk.com> Date: Wed Apr 24 01:24:03 2013 +0300 verion 1.0 commit 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 git tag http://git-scm.com/docs/git-tag git tag foo - will create a tag named foo to the current HEAD reference
  • 24. Merging Integrating two nodes in the DAG - that's all it is ... $> git log --pretty=oneline --graph --decorate --all * 3bd95903b3e2a3934b1d3bc1495f7c5c9ced5df2 (HEAD, master) Merge branch 'the-idea' | | * aedd0cd8ba404f292bdf3f9542d67285c489a143 (the-idea) Bumping version to 2.0 * | 1706dbd411de152c462172386eafa238fc50f50b This change ... conflict ... merging "the-idea" branch |/ * 8a7534e5ac1eb36ef21b8c4a06b8af5d59abee50 (second-idea) Adding hello.rb to repo * 38a5307967fe2c9f92eb3c5a46ccdcc18410b4f3 Adding README file $> git log commit 3bd95903b3e2a3934b1d3bc1495f7c5c9ced5df2 Merge: 1706dbd aedd0cd Author: Haggai Philip Zagury <hagzag@tikalk.com> Date: Tue Apr 23 22:34:54 2013 +0300 Merge branch 'the-idea' Conflicts: README
  • 27. Remote tracking Reference(s) The remote/master is the same type of reference like the "local" master but from a different namespace. .git/refs/remotes/... This namespace is mapped to the remote server ! - represented by a url 8a7534e5 43841a2f bd2510ea master HEAD* remotes/server/master