SlideShare a Scribd company logo
GIT 201 - A DEEPER LOOK AT GIT
Git Me With Your Best Shot
Arthur Doler
@arthurdoler
arthurdoler@gmail.com
We’ll be using the Git
command line…
Source: Giphy
“FUNDAMENTAL PARTICLES” OF GIT
Blob
artdoler@machine$ git ls-files --stage
100644 ac461d89cb0a217c2ee2bfcac33e1c27df7739a7 0 path/to/source/file.js
Tree
artdoler@machine$ git write-tree
cf09c37fdb1e4ba320d2ae08e9eb32d6913979e3
artdoler@machine$ git ls-tree cf09
040000 tree c98ef89a1fc979e593927666c058d15f8111c0bf path
Commit
artdoler@machine$ echo "Manual commit." | git commit-tree cf09
c26db2aec27b78aeaed82173ec5f5b2303931b29
artdoler@machine$ git log c26d
commit c26db2aec27b78aeaed82173ec5f5b2303931b29
Author: Art Doler art.doler@aviture.us.com
Date: Thu May 20 08:59:12 2016 -0500
Manual commit.
A GIT REPOSITORY
IS JUST GRAPHS OF COMMITS
What Git Manages For You
What To Actually Think About
Blob
Tree
Commit
Δ
Δ
Δ
Δ
Δ
Δ
Δ
Δ
ΔΔ
Δ
Δ
Δ
HOW DOES GIT MAKE DIFFS?
B
C
F
E
A
Commit 1 Commit 2
Directory Directory
Rename
Delete
Edit
Add
BRANCHES & TAGS
When I realize “DVCS” means I always get my own
branch
Source: Giphy
WHAT’S IN A NAME?
HEAD
ac461d89cb0a217c2ee2bfcac33e1c27df7739a7
feature/my_feature_branch
^ ~
B = A^ = A~ = A^1 = A~1
A
B
A = A^0
C
C = B^ = A^^ = A~~
C = A^1^1 = A~2
C ≠ A^2
develop
MERGING
When my coworker’s merge breaks my
feature
Source: Giphy
B = A^ = A~ = A^1 = A~1
A
B
A = A^0
C
D E
D = C^1 = C~ = B~2
develop
E = C^2 = B^^2 = A~2^2
develop branch_2
F G
F = C^^ = A~4
G = E~ = C^2^ = A~2^2~
C = B^ = A^^ = A~~
C = A^1^1 = A~2
C ≠ A^2
OPINION TIME
Source: Giphy
IF THE BEST WAY TO THINK ABOUT GIT
IS COMMIT TOPOLOGIES…
ONE CONCEPT, ONE COMMIT
“I don't know how many people
look at Al's progression of patches,
but they are stand-alone patches
on their own, while at the same
time _also_ being part of a larger
migration to the inscrutable goals
of Al - ie namespaces etc.
You may not realize just _how_
impressive that is, and what a
absolute wonder it is to work with
the guy.
Poetry in patches, indeed.”
- Linus Torvalds
On fa.linux.kernel, 27 Dec 2001
Source: Wikipedia
CLEAN CODE ↔ CLEAN HISTORY
PICK “TOO MANY COMMITS”
OVER “TOO FEW”
“History is the version of past events
that people have decided to agree
upon.”
- Attr. Napoleon Bonaparte
Source: Wikipedia
REBASING
When you learn to rebase like a boss
Source: Giphy
PUBLIC VERSUS PRIVATE BRANCHES
When you force push to
a
public branch
Source: Giphy
GARBAGE COLLECTION
Finding out git has a garbage collector
when it deletes your accidentally untracked
Source: Giphy
HISTORY METHODOLOGIES
Pure Merge (i.e. gitflow)
Pure Rebase (Keep Branch or Delete Branch)
Rebase Then Merge
Rebase With Squash (Mild/Major)
… A
D
E
F
Example Case: Feature
Develop
… B
F
Pure Merge
…
A
C D
E
G
Develop
Feature
…
B
Pure Rebase
(Keep or Delete Branch)
…
A
B C
D
Develop
Feature
Rebase Then Merge
…
A
C D
E
Develop
Feature
…
B
F
…
A
B D
E
Develop
FeatureF
Rebase With Squash
THANKS
When I accidentally
click ‘Merge pull
request’ instead of
‘Comment’ in GitHub
Source: Giphy
Arthur Doler
@arthurdoler
arthurdoler@gmail.com
RESOURCES
• Git from the Bottom Up (free!)
• http://ftp.newartisans.com/pub/git.from.bottom.up.pdf
• Gitflow
• http://nvie.com/posts/a-successful-git-branching-model/
• A Git Workflow for Agile Teams
• http://reinh.com/blog/2009/03/02/a-git-workflow-for-agile-teams.html
• Git Team Workflows: merge or rebase?
• http://blogs.atlassian.com/2013/10/git-team-workflows-merge-or-rebas
• Git Pro Book (also free!)
• http://git-scm.com/book
• Git pack files
• http://git-scm.com/book/en/Git-Internals-Packfiles
• http://stackoverflow.com/questions/5176225/are-gits-pack-files-deltas-r

More Related Content

PPTX
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
PPTX
Git 201 - A Deeper Look at Git @ KCDC 2016
PDF
Git meanings of -distributed-
KEY
Git Basics - RubyFest 2009
PPTX
Get going with_git_ppt
PDF
Software Dendrology by Brandon Bloom
PDF
Loading...git
PDF
сто газпром 9000 2006
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201 - A Deeper Look at Git @ KCDC 2016
Git meanings of -distributed-
Git Basics - RubyFest 2009
Get going with_git_ppt
Software Dendrology by Brandon Bloom
Loading...git
сто газпром 9000 2006

Viewers also liked (19)

PPTX
Bio-Degradable Track Mat
PPTX
JUSTMAKE就是美足膜系列(footsocks)
PPTX
this is me
PDF
сто газпром 2 3.2-106-2007
PPTX
65 Simpozijum farmaceutskih udruženja Srbije
PDF
Specsavers Annual Review 2015
PDF
Last jp403835m
PPTX
Leadership
PPT
4 th 209-美國報告
PDF
MD Merchem - Healthier Diet
DOC
RESUME DINESH
PDF
SLINGCO_OG_8pp_US_pages_150dpi
PDF
Temp Proc - GSX Ecalation Rev B
DOCX
RESUME 2015
PPTX
What does Bruce Lee, Voltron, and an Iceberg have in common with OWL?
DOCX
Resume new
PDF
B Section 16 AutoCAD Paperspace
PDF
Jacqueline B. Treash RESUME
PDF
Final demo
Bio-Degradable Track Mat
JUSTMAKE就是美足膜系列(footsocks)
this is me
сто газпром 2 3.2-106-2007
65 Simpozijum farmaceutskih udruženja Srbije
Specsavers Annual Review 2015
Last jp403835m
Leadership
4 th 209-美國報告
MD Merchem - Healthier Diet
RESUME DINESH
SLINGCO_OG_8pp_US_pages_150dpi
Temp Proc - GSX Ecalation Rev B
RESUME 2015
What does Bruce Lee, Voltron, and an Iceberg have in common with OWL?
Resume new
B Section 16 AutoCAD Paperspace
Jacqueline B. Treash RESUME
Final demo
Ad

Similar to Git 201 - A Deeper Look at Git @ Prairie.Code() 2016 (20)

PPTX
Git One Day Training Notes
PDF
Git essentials
PDF
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
PDF
M.Mozūras - git
PPTX
MakingGitWorkForYou
PPT
PDF
Git basics
PPTX
PPTX
Git workshop 33degree 2011 krakow
PDF
Don't fear the rebase
PDF
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
PDF
Git: a brief introduction
PDF
Getting Git Right
PDF
Becoming a Git Master - Nicola Paolucci
PDF
Git with the flow
PDF
Becoming a Git Master
PDF
Understanding git: Voxxed Vienna 2016
PPTX
Git more done
PDF
Version Control System - Git
PDF
Advanced Git
Git One Day Training Notes
Git essentials
Vincit Teatime 2015.2 - Otto Kekäläinen: Don't be a git
M.Mozūras - git
MakingGitWorkForYou
Git basics
Git workshop 33degree 2011 krakow
Don't fear the rebase
Git Is A State Of Mind - The path to becoming a Master of the mystic art of Git
Git: a brief introduction
Getting Git Right
Becoming a Git Master - Nicola Paolucci
Git with the flow
Becoming a Git Master
Understanding git: Voxxed Vienna 2016
Git more done
Version Control System - Git
Advanced Git
Ad

More from Arthur Doler (20)

DOCX
The Saboteur in Your Retrospectives: Handout
PPTX
The Developer's Guide to Learning
PPTX
The Whys and Hows of Impostor Syndrome and the Illusion of Transparency
DOCX
Let's Talk About Mental Health Handout
PPTX
Let's Talk About Mental Health
PPTX
Feedback Workshop KCDC2018
PPTX
Let's Talk About Mental Health - KCDC 2018
DOCX
Let's Talk About Mental Health Handout - KCDC 2018
DOCX
Let's Talk About Mental Health Handout - NDC Oslo 2018
PPTX
Let's Talk About Mental Health - NDC Oslo 2018
DOCX
Let's Talk About Mental Health Handout - Nebraska.Code 2018
PPTX
Let's Talk About Mental Health - Nebraska.Code 2018
PPTX
The Developer's Guide to Learning - 200OK 2018
PPTX
The Developer's Guide to Learning - Codestock 2018
PPTX
What Makes You DO Stuff? The Psychology of Motivation - Codestock 2018
DOCX
What Makes You DO Stuff? The Psychology of Motivation - Handout - Codestock 2018
PPTX
Let's Talk About Mental Health - DevUp 2017
DOCX
Let's Talk About Mental Health - Handout - DevUp 2017
PPTX
The Developer's Guide to Learning Effectively
DOCX
The Saboteur in Your Retrospectives: How Your Brain Works Against You - The H...
The Saboteur in Your Retrospectives: Handout
The Developer's Guide to Learning
The Whys and Hows of Impostor Syndrome and the Illusion of Transparency
Let's Talk About Mental Health Handout
Let's Talk About Mental Health
Feedback Workshop KCDC2018
Let's Talk About Mental Health - KCDC 2018
Let's Talk About Mental Health Handout - KCDC 2018
Let's Talk About Mental Health Handout - NDC Oslo 2018
Let's Talk About Mental Health - NDC Oslo 2018
Let's Talk About Mental Health Handout - Nebraska.Code 2018
Let's Talk About Mental Health - Nebraska.Code 2018
The Developer's Guide to Learning - 200OK 2018
The Developer's Guide to Learning - Codestock 2018
What Makes You DO Stuff? The Psychology of Motivation - Codestock 2018
What Makes You DO Stuff? The Psychology of Motivation - Handout - Codestock 2018
Let's Talk About Mental Health - DevUp 2017
Let's Talk About Mental Health - Handout - DevUp 2017
The Developer's Guide to Learning Effectively
The Saboteur in Your Retrospectives: How Your Brain Works Against You - The H...

Recently uploaded (20)

PPTX
Machine Learning_overview_presentation.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
Machine Learning_overview_presentation.pptx
MYSQL Presentation for SQL database connectivity
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
Per capita expenditure prediction using model stacking based on satellite ima...
20250228 LYD VKU AI Blended-Learning.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The Rise and Fall of 3GPP – Time for a Sabbatical?
The AUB Centre for AI in Media Proposal.docx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
sap open course for s4hana steps from ECC to s4
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
Spectral efficient network and resource selection model in 5G networks
Dropbox Q2 2025 Financial Results & Investor Presentation
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Encapsulation_ Review paper, used for researhc scholars

Git 201 - A Deeper Look at Git @ Prairie.Code() 2016

Editor's Notes

  • #7: A quick overview of the basic structure for git – blobs are contained by trees, which contain each other, and which are contained by a commit. Blobs and trees are subatomic particles, composing the literally atomic commits. Like reality, almost all of the time, just knowing how atoms work is enough. Sometimes there’s effects that make no sense which require subatomic knowledge, but until those points it’s not necessary.
  • #9: Commits and commit topologies are the most important pieces of Git. The “atomic” commits form into “molecules” of topologies (typically called branches). The edges of the DAG are then the deltas.
  • #11: Here we have two commits, side by side, and we’re going to try to get a diff between the two. Commit 1 has three files – one in the root of the repo (File 1) and two in a directory (helpfully called Directory), which are File 3 and File 4. Commit 2 has three files – File 2 in the root and File 4 and File 5 in Directory. File 1 and 2 have the same blob: identically the same. Git will (sometimes) reinterpret this as a rename. File 3 is in Commit 1 but not in Commit 2, so it’s a delete. File 4 has different blobs in the two commits: it’s a change and a diff will be generated. File 5 is in Commit 2 but not in Commit 1: it’s an add.
  • #12: Time to go to the command line. Explain what you’re doing – committing data to be served via a service. In this case, MTG decks. Magic has different ways to play it, called “formats”. We’re tracking formats in different branches, because Reasons. New tournament – block format! So “git checkout –b mtg_2014_block” There are uncommitted changes, so “git add .” then “git commit –m “New decks.”” Talk about what a branch is – a pointer to a specific commit. A major tournament is over so we’re making a tag for it. “git tag –a SCG_Open_07_2014 –m “SCG Open Finalized Decks.”” Lightweight tags are just like (mostly) immutable branches. Annotated tags identify the tagger, the message, the date, and have a checksum. Talk about how a branch is actually a pointer to the entire DAG (directed acyclical graph) at that point. Two important things to realize: A branch is not constrained by anything – any branch can point to any commit (even HEAD or master!). The hash for each commit includes its parent – that means ANY history change will cascade through the DAG! We’ll see an example when we rebase.
  • #15: Different ways to get upstream in your repository… note that these work on ANY name for a commit! And they can be chained, like in the last example, since the valid names for a commit (sha1, tag, branch, etc) plus the ^ and ~ operators are a valid DSL.
  • #16: Anything valid in block format is valid in standard format, and so we need to merge those commits in: “git checkout mtg_2014_standard”, “git merge --no-ff mtg_2014_block” The “no-ff” option on a merge performs a guaranteed merge commit – by default git will try to avoid making a merge commit if it can, through doing what is basically a rebase. –no-ff forces it to make a merge commit instead.
  • #17: Different ways to get upstream in your repository… note that these work on ANY name for a commit! And they can be chained, like in the last example, since the valid names for a commit (sha1, tag, branch, etc) plus the ^ and ~ operators are a valid DSL.
  • #25: Example time yet again. We have a repo. We’ve been doing on-the-ground reporting for a local tournament and we’ve made a bunch of commits as we went so we didn’t lose anything. Could push this, but it looks terrible. What to do? Rebase! Interactive rebase – git pops open whatever editor we have configured. One row = one commit, in reverse order. It does this in an editor so you can copy and paste, and so you can change the command from “pick” to something else. Show the list in gvim next to the list in gitviz. There is one reorder, then two fixups, then one commit to reword and one commit to amend. What if there had been commits on block we had to worry about? Rebase to the rescue! Normal rebase. Call out how it applies each commit in turn. We could have done both at once (and we should have!) but I broke it apart for clarity.
  • #28: Example time again. git branch –D mtg_2014_legacy ./gcscript.sh See!
  • #30: A discussion of git workflows – I’m going to exclude the issues caused by external tools here and focus only on git. It – essentially – boils down to four types of git workflows. We’ll work through the same example with each of the four types – just as a visual, to avoid a lot of unnecessary typing.
  • #31: “Pure “ merge – using only the merge command (with --no-ff option). First merge develop into the feature to get the changes from Feature Branch B, accounting for conflicts if necessary. Then merge the feature branch into develop.
  • #32: “Pure” rebase – First rebase the feature branch onto current develop to pick up branch B’s changes. Then alter develop’s head ref to point to F, either via manually editing it (bad!) or a fast-forward merge.
  • #33: Rebase then merge – First rebase the feature branch onto current develop to pick up branch B’s changes. Then merge feature back into develop, using a --no-ff merge, to retain the merge commit.
  • #34: Rebase then squash – First rebase the feature branch onto current develop to pick up branch B’s changes. Then interactive rebase to squash to one or a few large commits. Then fast-forward merge feature into develop.
  • #35: ??????
  • #38: SO MUCH STUFF TO READ, you guys. Seriously.