SlideShare a Scribd company logo
Internals Usage Distribution Merging and Rebasing Extras
Git for mere mortals
https://github.com/Kelsin/git-presentation
Christopher Giroir
July 26th, 2011
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
1 Internals
Objects
Branches and Tags
2 Usage
Creating and Commiting
Inspection
3 Distribution
Advantages
Architecture
Command Examples
4 Merging and Rebasing
Merging
Rebase
5 Extras
Remotes
Misc
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Objects
Object Store
The git object store is a big black box and we like it that way.
It was written for speed and correctness
Comparisons
More information than CVS
More sane than SVN
More efficient than Mercurial
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Objects
Blobs
_^]XYZ[Blob
Blobs store file data (text or binary).
Labeled by SHA1. If the content changes, so does the SHA.
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Objects
Trees
_^]XYZ[Blob
_^]XYZ[Tree //
??
_^]XYZ[Blob
Trees point to blobs
Represent the entire state of the working directory
Also labeled by SHA’s.
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Objects
Commits
onmlhijkCommit _^]XYZ[Blob
onmlhijkCommit
OO
//_^]XYZ[Tree
CC§§§§§§§§§§§§§
//_^]XYZ[Blob
Points to a tree object and parent commit(s)
Stores author and date information
Labeled by SHA’s.
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Objects
Important Distinction!
Commits link to entires TREES not DIFFS.
Diffs are not stored in git, they are computed.
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Branches and Tags
Pointers
Most other things in git are pointers to commits.
?>=<89:;a //
v3.0.1
?>=<89:;b //
bbbbbbbbb
Master
?=89:;c //?=89:;d //?=89:;e
SAVE-465
?=89:;g //
origin/SAVE-576
?=89:;h //?=89:;i
SAVE-576
Branches are just labels to commit SHA’s
Tags are just labels with meta information
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Branches and Tags
Rewriting History
Rewriting a commit changes it’s SHA
Any commit after it changes as well
Most branch operations are quick and painless
Can shoot yourself in the foot and heal it back up again
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Creating and Commiting
Starting Out
Setting User Info
git config --global user.name Christopher Giroir
git config --global user.email kelsin@valefor.com
Completely New Repo
cd dir-with-code
git init
Cloning any accessible repo
git clone git@github.com:Kelsin/configs.git
cd configs
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Creating and Commiting
Commits
Initial Commit
git add .
git commit -m Initial Commit
Editing some files
git add edited-file.rb
git commit -m Improved everything
Adding to previous commit
git add edited-file.rb
git commit --amend
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Inspection
Status and Diffs
Normal Status
git status
What’s current changed?
git diff
Changes from only one file
git diff example-file.rb
Changes between branches
git diff master
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Inspection
Show and Log
Show current commit
git show
Show some other commit
git show 234ab32
Show log of recent commits
git log
Show pretty log
git log --graph --decorate --oneline
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Inspection
Refs and Objects
By commit id
git show 234ab32
By branch
git show master
By tag
git show v3.0.2
Relative
git show HEAD^
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Advantages
Distributed Source Control
Only difference from remote and local (normally): working
directories
Can function offline
Can “push” and “pull” from each other, as well as servers
Each of our computers serves as a backup of the server
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Architecture
Location Descriptions
Git has 4 locations where commits are stored
Remote Repo Any remote object store
Local Repo You local object store
Index A single spot to “stage” commits
Working Directory These are the files you are editing
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Command Examples
Locations and Commands
Working
git add

Index
git commit
Local Repo
git push
##
git checkout
gg
Remote Repo
git fetch
cc
BC@A
git pull
OO
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Merging
Fast Forward Merging
git checkout master
git merge SAVE-234
?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;e
Master
SAVE-234
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Merging
Merging
git checkout master
git merge SAVE-234
?=89:;a //?=89:;b //
aaaaaaaaa
?=89:;c //?=89:;d //?=89:;e //?=89:;76540123j
Master
?=89:;g //?=89:;h //?=89:;i
@@¢¢¢¢¢¢¢¢¢
SAVE-234
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Merging
No Fast Forward Merging
git checkout master
git merge --no-ff SAVE-234
?=89:;a //?=89:;b
bbbbbbbbb
//?=89:;76540123f
Master
?=89:;c //?=89:;d //?=89:;e
@@         
SAVE-234
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Rebase
Rebase
git checkout SAVE-234
git rebase master
?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;e
wwooooooooooooooooo
Master
GFED@ABC?=89:;g //GFED@ABC?=89:;h //ONMLHIJKGFED@ABCi
SAVE-234
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Remotes
Remote Commands
Adding remote
git remote add origin
git@github.com:Kelsin/configs.git
Fetch all remote objects
git fetch
Show all branches
git branch -a
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Remotes
Pushing
Push objects from source to destination
git push origin source:destination
Removing remote branch
git push origin :destination
Setting upstream
git push -u origin SAVE-453
Force pushes
git push -f origin SAVE-453
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Remotes
Pulling
Pull in remote changes
git pull origin master
Special case
Executes:
git fetch
git merge
Merges in to your current branch
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Misc
Git Config File
My git config is available at
https://github.com/Kelsin/configs/blob/master/.gitconfig
Push defaults
Commiter name and email
Color settings
Aliases
Christopher Giroir Git for mere mortals
Internals Usage Distribution Merging and Rebasing Extras
Misc
Some Tips
Always work on branches
When in doubt use GitX or gitk to see what you are doing
When in doubt save a new branch so you can always get back
Add the current git branch into your prompt
Explore with rebase and cleaning up code before final push
Christopher Giroir Git for mere mortals

More Related Content

PDF
Level Up Your Git and GitHub Experience by Jordan McCullough and Brent Beer
PDF
Git in a nutshell
PPTX
GIT in a nutshell
PDF
Git Real
KEY
Gittalk
PDF
Git - Get Ready To Use It
KEY
Git: from Novice to Expert
PPTX
Level Up Your Git and GitHub Experience by Jordan McCullough and Brent Beer
Git in a nutshell
GIT in a nutshell
Git Real
Gittalk
Git - Get Ready To Use It
Git: from Novice to Expert

What's hot (20)

PDF
git. WTF is it doing anyway?
PPTX
Introduction To Git Workshop
PDF
Code reviews vs Pull requests
KEY
Git Magic: Versioning Files like a Boss
PDF
Beating Python's GIL to Max Out Your CPUs
DOCX
Bitbucket
PDF
Git & GitHub WorkShop
KEY
The everyday developer's guide to version control with Git
PPTX
Git session Dropsolid.com
PDF
Git real slides
PDF
Introduction to Git Version Control System
PDF
[로켓 자바] Part 1 성능 튜닝 마인드 확립
PDF
PDF
Git: An introduction of plumbing and porcelain commands
PDF
JPA Week5. Join Fetch
PDF
git and github
PPTX
Git-ing out of your git messes
PDF
DevOpsDays PDX - Batteries Included: Enabling Community Contribution
PDF
Tracking large game assets with Git LFS
PPTX
Git 101 for Beginners
git. WTF is it doing anyway?
Introduction To Git Workshop
Code reviews vs Pull requests
Git Magic: Versioning Files like a Boss
Beating Python's GIL to Max Out Your CPUs
Bitbucket
Git & GitHub WorkShop
The everyday developer's guide to version control with Git
Git session Dropsolid.com
Git real slides
Introduction to Git Version Control System
[로켓 자바] Part 1 성능 튜닝 마인드 확립
Git: An introduction of plumbing and porcelain commands
JPA Week5. Join Fetch
git and github
Git-ing out of your git messes
DevOpsDays PDX - Batteries Included: Enabling Community Contribution
Tracking large game assets with Git LFS
Git 101 for Beginners
Ad

Similar to Git Presentation - Handout (20)

PDF
Git 入门 与 实践
PDF
PDF
Git 入门与实践
PDF
Git Commands Every Developer Should Know?
PDF
Git and git hub
PDF
Distributed Developer Workflows using Git
PPTX
Introduction to Git and Github
KEY
Git Tech Talk
PDF
Git - An Introduction
KEY
Gitting the Most From Git
KEY
Git Distributed Version Control System
PPTX
Working in Team using Git in Unity
PPT
Git presentation
PDF
Git training v10
PPTX
An introduction to Git
PDF
Git & gitflow
DOCX
Git github
ODP
Introduction to Git (Greg Lonnon)
PPT
Github By Nyros Developer
PDF
Git interview questions | Edureka
Git 入门 与 实践
Git 入门与实践
Git Commands Every Developer Should Know?
Git and git hub
Distributed Developer Workflows using Git
Introduction to Git and Github
Git Tech Talk
Git - An Introduction
Gitting the Most From Git
Git Distributed Version Control System
Working in Team using Git in Unity
Git presentation
Git training v10
An introduction to Git
Git & gitflow
Git github
Introduction to Git (Greg Lonnon)
Github By Nyros Developer
Git interview questions | Edureka
Ad

Recently uploaded (20)

PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
Spectroscopy.pptx food analysis technology
PPT
Teaching material agriculture food technology
PDF
Approach and Philosophy of On baking technology
PDF
KodekX | Application Modernization Development
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Understanding_Digital_Forensics_Presentation.pptx
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
20250228 LYD VKU AI Blended-Learning.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Spectroscopy.pptx food analysis technology
Teaching material agriculture food technology
Approach and Philosophy of On baking technology
KodekX | Application Modernization Development
Chapter 3 Spatial Domain Image Processing.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Reach Out and Touch Someone: Haptics and Empathic Computing
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
The AUB Centre for AI in Media Proposal.docx
Building Integrated photovoltaic BIPV_UPV.pdf
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Unlocking AI with Model Context Protocol (MCP)

Git Presentation - Handout

  • 1. Internals Usage Distribution Merging and Rebasing Extras Git for mere mortals https://github.com/Kelsin/git-presentation Christopher Giroir July 26th, 2011 Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras 1 Internals Objects Branches and Tags 2 Usage Creating and Commiting Inspection 3 Distribution Advantages Architecture Command Examples 4 Merging and Rebasing Merging Rebase 5 Extras Remotes Misc Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Objects Object Store The git object store is a big black box and we like it that way. It was written for speed and correctness Comparisons More information than CVS More sane than SVN More efficient than Mercurial Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Objects Blobs _^]XYZ[Blob Blobs store file data (text or binary). Labeled by SHA1. If the content changes, so does the SHA. Christopher Giroir Git for mere mortals
  • 2. Internals Usage Distribution Merging and Rebasing Extras Objects Trees _^]XYZ[Blob _^]XYZ[Tree // ?? _^]XYZ[Blob Trees point to blobs Represent the entire state of the working directory Also labeled by SHA’s. Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Objects Commits onmlhijkCommit _^]XYZ[Blob onmlhijkCommit OO //_^]XYZ[Tree CC§§§§§§§§§§§§§ //_^]XYZ[Blob Points to a tree object and parent commit(s) Stores author and date information Labeled by SHA’s. Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Objects Important Distinction! Commits link to entires TREES not DIFFS. Diffs are not stored in git, they are computed. Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Branches and Tags Pointers Most other things in git are pointers to commits. ?>=<89:;a // v3.0.1 ?>=<89:;b // bbbbbbbbb Master ?=89:;c //?=89:;d //?=89:;e SAVE-465 ?=89:;g // origin/SAVE-576 ?=89:;h //?=89:;i SAVE-576 Branches are just labels to commit SHA’s Tags are just labels with meta information Christopher Giroir Git for mere mortals
  • 3. Internals Usage Distribution Merging and Rebasing Extras Branches and Tags Rewriting History Rewriting a commit changes it’s SHA Any commit after it changes as well Most branch operations are quick and painless Can shoot yourself in the foot and heal it back up again Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Creating and Commiting Starting Out Setting User Info git config --global user.name Christopher Giroir git config --global user.email kelsin@valefor.com Completely New Repo cd dir-with-code git init Cloning any accessible repo git clone git@github.com:Kelsin/configs.git cd configs Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Creating and Commiting Commits Initial Commit git add . git commit -m Initial Commit Editing some files git add edited-file.rb git commit -m Improved everything Adding to previous commit git add edited-file.rb git commit --amend Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Inspection Status and Diffs Normal Status git status What’s current changed? git diff Changes from only one file git diff example-file.rb Changes between branches git diff master Christopher Giroir Git for mere mortals
  • 4. Internals Usage Distribution Merging and Rebasing Extras Inspection Show and Log Show current commit git show Show some other commit git show 234ab32 Show log of recent commits git log Show pretty log git log --graph --decorate --oneline Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Inspection Refs and Objects By commit id git show 234ab32 By branch git show master By tag git show v3.0.2 Relative git show HEAD^ Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Advantages Distributed Source Control Only difference from remote and local (normally): working directories Can function offline Can “push” and “pull” from each other, as well as servers Each of our computers serves as a backup of the server Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Architecture Location Descriptions Git has 4 locations where commits are stored Remote Repo Any remote object store Local Repo You local object store Index A single spot to “stage” commits Working Directory These are the files you are editing Christopher Giroir Git for mere mortals
  • 5. Internals Usage Distribution Merging and Rebasing Extras Command Examples Locations and Commands Working git add Index git commit Local Repo git push ## git checkout gg Remote Repo git fetch cc BC@A git pull OO Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Merging Fast Forward Merging git checkout master git merge SAVE-234 ?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;e Master SAVE-234 Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Merging Merging git checkout master git merge SAVE-234 ?=89:;a //?=89:;b // aaaaaaaaa ?=89:;c //?=89:;d //?=89:;e //?=89:;76540123j Master ?=89:;g //?=89:;h //?=89:;i @@¢¢¢¢¢¢¢¢¢ SAVE-234 Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Merging No Fast Forward Merging git checkout master git merge --no-ff SAVE-234 ?=89:;a //?=89:;b bbbbbbbbb //?=89:;76540123f Master ?=89:;c //?=89:;d //?=89:;e @@          SAVE-234 Christopher Giroir Git for mere mortals
  • 6. Internals Usage Distribution Merging and Rebasing Extras Rebase Rebase git checkout SAVE-234 git rebase master ?=89:;a //?=89:;b //?=89:;c //?=89:;d //?=89:;e wwooooooooooooooooo Master GFED@ABC?=89:;g //GFED@ABC?=89:;h //ONMLHIJKGFED@ABCi SAVE-234 Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Remotes Remote Commands Adding remote git remote add origin git@github.com:Kelsin/configs.git Fetch all remote objects git fetch Show all branches git branch -a Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Remotes Pushing Push objects from source to destination git push origin source:destination Removing remote branch git push origin :destination Setting upstream git push -u origin SAVE-453 Force pushes git push -f origin SAVE-453 Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Remotes Pulling Pull in remote changes git pull origin master Special case Executes: git fetch git merge Merges in to your current branch Christopher Giroir Git for mere mortals
  • 7. Internals Usage Distribution Merging and Rebasing Extras Misc Git Config File My git config is available at https://github.com/Kelsin/configs/blob/master/.gitconfig Push defaults Commiter name and email Color settings Aliases Christopher Giroir Git for mere mortals Internals Usage Distribution Merging and Rebasing Extras Misc Some Tips Always work on branches When in doubt use GitX or gitk to see what you are doing When in doubt save a new branch so you can always get back Add the current git branch into your prompt Explore with rebase and cleaning up code before final push Christopher Giroir Git for mere mortals