SlideShare a Scribd company logo
GIT 201 - A DEEPER LOOK AT GIT
Git Me With Your Best Shot
Arthur Doler
@arthurdoler
arthurdoler@gmail.com
TITANIUM SPONSORS
Platinum Sponsors
Gold Sponsors
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
QUESTIONS?
When I accidentally
click ‘Merge pull
request’ instead of
‘Comment’ in GitHub
Source: Giphy
•Do you live in the Omaha/Lincoln area?
•Do you work in development or in another
profession in tech?
•Are you a consumer of mental health services or
have you been diagnosed with a mental disorder?
•Are you interested in being a founding member of a
peer-support group for technical mental health
consumers?
Talk to me afterward, or email me at
arthurdoler@gmail.com
(or Twitter DM or LinkedIn message or G+
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 @ MDC 2016
PDF
Software Dendrology by Brandon Bloom
ODP
Sharing Nicely (at Pecha Kucha Cape Town)
PDF
How not to delete your important files
PDF
Simple tricks to speed you up on the command line
DOCX
Git bash
DOCX
Hesh
Git 201: A Deeper Look at Git (Nebraska.Code 2016)
Git 201 - A Deeper Look at Git @ MDC 2016
Software Dendrology by Brandon Bloom
Sharing Nicely (at Pecha Kucha Cape Town)
How not to delete your important files
Simple tricks to speed you up on the command line
Git bash
Hesh

Viewers also liked (19)

PDF
Sergliflozin etabonate 408504-26-7-api
PDF
Sda 23-2008
PDF
Bøf & Vin Sushi menu
PDF
PDF
A journey to Agile, the Vietnamese offshore experience
PPTX
9-1-1 Location Accuracy
PPT
PPTX
VARANASI - NEPAL
PDF
Key performance indicators for customer care
PDF
Possehl Betonherstel & Onderhoud
PDF
SAIL Magazine 2016 PDF
PDF
A framework for the design and execution of heterogeneous distributed applica...
PPTX
Technowebsy - Logo design process
DOCX
Pauls cv copy !
PDF
NM_Thesis
DOC
Resume
PPTX
Abcd 2 songs lyrics
PDF
Proyecto Yogurt-K-Cero
PPTX
Russell Morgan Slideshare Dec 16
Sergliflozin etabonate 408504-26-7-api
Sda 23-2008
Bøf & Vin Sushi menu
A journey to Agile, the Vietnamese offshore experience
9-1-1 Location Accuracy
VARANASI - NEPAL
Key performance indicators for customer care
Possehl Betonherstel & Onderhoud
SAIL Magazine 2016 PDF
A framework for the design and execution of heterogeneous distributed applica...
Technowebsy - Logo design process
Pauls cv copy !
NM_Thesis
Resume
Abcd 2 songs lyrics
Proyecto Yogurt-K-Cero
Russell Morgan Slideshare Dec 16
Ad

Similar to Git 201 - A Deeper Look at Git @ KCDC 2016 (20)

PPTX
Git 201 - A Deeper Look at Git @ Prairie.Code() 2016
PDF
Git branching model_for_tap_team
PDF
Version Control and Git - GitHub Workshop
PDF
slides.pdf
PDF
slides.pdf
PDF
git & GitHub workshop
PDF
That's (g)it! par Sébastien Dawans CETIC
KEY
Working with Git
PDF
Introduction to Git for Non-Developers
PDF
Introduction to Git for Non-Developers
PDF
Git Without Puns
PPTX
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
PDF
Git the Docs: Learning Git in a safe space
PDF
Tracking huge files with Git LFS (GlueCon 2016)
PDF
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
PPTX
Git Basic
ODP
Introduction to Git (Greg Lonnon)
PDF
Presentacion git
PDF
Tracking large game assets with Git LFS
PDF
Git Power Routines
Git 201 - A Deeper Look at Git @ Prairie.Code() 2016
Git branching model_for_tap_team
Version Control and Git - GitHub Workshop
slides.pdf
slides.pdf
git & GitHub workshop
That's (g)it! par Sébastien Dawans CETIC
Working with Git
Introduction to Git for Non-Developers
Introduction to Git for Non-Developers
Git Without Puns
YET ANOTHER INTRODCTION AND AN EXAMPLE HOW NOT TO USE BAD PRESENTATION STYLES
Git the Docs: Learning Git in a safe space
Tracking huge files with Git LFS (GlueCon 2016)
Cool Git Tricks (That I Learn When Things Go Badly) [1/2]
Git Basic
Introduction to Git (Greg Lonnon)
Presentacion git
Tracking large game assets with Git LFS
Git Power Routines
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)

PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
cuic standard and advanced reporting.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Encapsulation theory and applications.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Electronic commerce courselecture one. Pdf
PDF
Unlocking AI with Model Context Protocol (MCP)
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Approach and Philosophy of On baking technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PPTX
MYSQL Presentation for SQL database connectivity
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
MIND Revenue Release Quarter 2 2025 Press Release
cuic standard and advanced reporting.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Review of recent advances in non-invasive hemoglobin estimation
Programs and apps: productivity, graphics, security and other tools
Encapsulation theory and applications.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
“AI and Expert System Decision Support & Business Intelligence Systems”
Electronic commerce courselecture one. Pdf
Unlocking AI with Model Context Protocol (MCP)
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Approach and Philosophy of On baking technology
NewMind AI Weekly Chronicles - August'25 Week I
The AUB Centre for AI in Media Proposal.docx
Diabetes mellitus diagnosis method based random forest with bat algorithm
MYSQL Presentation for SQL database connectivity
sap open course for s4hana steps from ECC to s4
Reach Out and Touch Someone: Haptics and Empathic Computing
Mobile App Security Testing_ A Comprehensive Guide.pdf

Git 201 - A Deeper Look at Git @ KCDC 2016

Editor's Notes

  • #8: 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.
  • #10: 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.
  • #12: 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.
  • #13: 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.
  • #16: 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.
  • #17: 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.
  • #18: 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.
  • #26: 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.
  • #29: Example time again. git branch –D mtg_2014_legacy ./gcscript.sh See!
  • #31: 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.
  • #32: “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.
  • #33: “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.
  • #34: 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.
  • #35: 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.
  • #36: ??????
  • #39: SO MUCH STUFF TO READ, you guys. Seriously.