SlideShare a Scribd company logo
git more done
Kwen Peterson
Senior Software Developer @ Raven
kwen.peterson@gmail.com
@kwenarik
"You're already in the top tier of developers just
by showing up here tonight. I don't know how
talented you are, how much experience you have,
but you showed up. You're putting yourself out
there because you care to improve. Thanks for
caring.โ€œ โ€“ Scott Hanselman
Distributed
โ€ข One of the coolest features of any of the
Distributed VCSs, Git included, is that it isnโ€Ÿt
centralized.
โ€“ This means that even if you're using a centralized
workflow, every user has what is essentially a full
backup of the main server, each of which could be
pushed up to replace the main server in the event of a
crash or corruption.
โ€“ There is basically no single point of failure with a
distributed VCS.
Git is Fast
โ€ข Git is extremely fast. Since all operations (except
for push and fetch) are local there is no network
latency involved to:
โ€“
โ€“
โ€“
โ€“
โ€“

Perform a diff.
View file history.
Commit changes.
Merge branches.
Obtain any other revision of a file (not just the prior
committed revision).
โ€“ Switch branches.
Git is orders of
magnitude faster than SVN.
Operation

Git

SVN

Speed

Commit Files (A)

0.64

2.60

4x

Commit Images
(B)

1.53

24.70

16x

Diff Current

0.25

1.09

4x

Diff Recent

0.25

3.99

16x

Diff Tags

1.17

83.57

71x

Log (50)

0.01

0.38

31x

Log (All)

0.52

169.20

325x

Log (File)

0.60

82.84

138x

Update

0.90

2.82

3x

Blame

1.91

3.04

1x
Git is Small
โ€ข Git's repository and working directory sizes are extremely small
when compared to SVN.
โ€“ The Mozilla repository is reported to be almost 12 Gb stored across 240,000 files
in SVN.
โ€“ The exact same history is stored in Git using two files totaling just over 420 Mb.

โ€ข This means that SVN requires 30x the disk space to store the same
history!
โ€“ One of the reasons for the smaller repo size is that an SVN working directory
always contains two copies of each file: one for the user to actually work with and
another hidden in .svn/ to aid operations such as status, diff and commit.
โ€“ In contrast a Git working directory requires only one small index file that stores
about 100 bytes of data per tracked file. On projects with a large number of files
this can be a substantial difference in the disk space required per working copy.
Git is *
โ€ข GitHub
โ€“ 3 million+ users
โ€“ 5 million+ repositories
โ€“ THE place for open-source projects

โ€ข Merging & Branching are easy
โ€“ (unlike in many centralized systems)
The branch Dilemma
I have a 120 hour work package to do!
SVN:
โ€“ sit on 3 weeks worth of changes unversioned and then finally push 1
massive commit?
โ€“ push updates to trunk/branch as necessary and possibly break
functionality for anyone else working on project (but get to keep commit
history, and not have 1 massive commit)

Git:
โ€“ make daily commits to my local branch (full history, able to rollback to
intermediate stages!)
โ€“ merge in changes that others have pushed to the master branch at my
convenience
โ€“ hold off pushing to master until my code is fully polished and tested out,
minimizing impact on other developers
Code Reviews
โ€ข SVN
โ€“ Make a patch of uncommitted changes and send it
to another developer, and hope that they have an
SVN branch at the exact commit as yours to apply it
to.

โ€ข

Git
โ€“

Push a copy of your local branch (and all its
commits) out to a remote branch on a repository,
where anyone can easily pull down a copy and build
your code, no matter where there current branch is.
git-svn
โ€ข โ€œGit is the best SVN client out there.โ€ โ€“ Keith
Dahlby
โ€ข Gives you ALL the local repository benefits of
git, while letting you treat your SVN repo as โ€žjust
another remoteโ€Ÿ
Subversion-Style Workflow
Integration Manager Workflow
Dictator & Lieutenants Workflow
Felix Baumgartner โ€“ Red Bull
Creating a Repository
โ€ข git init
โ€“ Creates an empty repository at current location

โ€ข git clone <url>
โ€“ Creates a local copy of an existing repository
โ€“ Examples:
โ€ข git clone http://github.com/jquery/jquery.git
Working with Remotes
โ€ข git remote add <name> <url>
โ€“ Maps a remote
โ€“ Example:
git remote kwen git://source/kwen-test.git

โ€ข git remote show <name>
โ€“ Displays a list of branches on the remote, any local
branches that track them, fetch URL, etc.

โ€ข git remote rm <name>
โ€ข git remote rename <old> <new>
Working with Branches
โ€ข git checkout <branch>
โ€“ Change to the specified local branch

โ€ข git branch <name> <remote>/<branch>
โ€“ Create a local branch that tracks the remote branch
โ€“ Example: git branch milestone3 kwen-test/milestone3

โ€ข git checkout โ€“b <name> <remote>/<branch>
โ€“ Creates a new local branch and immediately checks it out
โ€“ Example: git co โ€“b codereview kwen-test/milestone4
Dealing with Changes
โ€ข git st
โ€“ Shows you the status of currently modified files (tracked &
untracked)

โ€ข git add <file> (use a gui instead!)
โ€“ adds the specified file to the list of tracked changes

โ€ข git commit โ€“m <message> (use a gui instead!)
โ€“ Commits all tracked changes to the current branch

โ€ข git reset HEAD โ€“hard
โ€“ Reset current branch and lose ALL changes

โ€ข git stash <tag>
โ€“ Store all current changes away temporarily
โ€“ The tag is optional, and it will generate one for you if not provided

โ€ข git stash apply <tag>
โ€“ Reapply the last set of stashed changes onto
the current branch
Pushing and Pulling Changes
โ€ข git fetch <name>
โ€“ Gets the latest updates from the remote, but does NOT apply them
โ€“ Example: git fetch origin

โ€ข git pull <remote> <branch>
โ€“ Runs git fetch and then git merge
โ€“ If you are on a branch that already tracks a remote, you can just use git
pull, and it will merge any updates in the tracked remote branch into your
local branch.
โ€“ Can pass a --rebase parameter to rebase instead of merge

โ€ข git push <remote> <name>:<branch>
โ€“ Pushes the updates in my current local branch out to a remote branch
โ€“ Example: git push origin milestone3:milestone3
Git Trivia
1. Git push origin master:master
2. Git push origin +master:master

3. Git push origin โ€“f master:master
Creating & Applying Patches
โ€ข git format-patch <branch>
โ€“ Creates patches for the diff between the current branch & <branch>
โ€“ Example: My local dev branch has updates that have not been
committed to origin/dev yet, but that I need to send to Wes.
Running git format-patch origin/dev creates patches for each of the
commits that are on my local dev branch that are not in origin/dev.

โ€ข git format-patch -#
โ€“ Same as above, except this method simply takes the last X
commits and creates patches for them.
โ€“ Example: git format-patch -3 (creates patches for the last 3 commits
you made on this branch)

โ€ข git am -3 โ€“s โ€“i <file or folder>
โ€“ Apply the specified patches to the current branch
โ€“ Example: git am -3 โ€“s โ€“i patches/* (applies all the patches located
in my patches folder)
Copy/Paste a commit locally
โ€ข Git cherry-pick <hash>
โ€“ Copies the changeset for the given commit onto the
current branch
โ€“ (Great way to apply a hotfix to multiple different
branches.)

*
Bug, orโ€ฆ

https://twitter.com/pardel/status/372750244963819522/photo/1
https://twitter.com/GeorgeTakei/status/385913390377750528/photo/1
Common git branching strategy
โ€ข 3 core branches: master, dev, release
โ€“ Master is โ€œthe truthโ€ and should always be in a stable,
fully-functional state. This is where new topic/feature
branches are cloned from. (nightly builds)
โ€“ Dev is where integration testing happens. This is
where topic branches are pushed and tested PRIOR
to being signed off on as stable enough to go to
master. (continuous integration, test environment)
โ€“ Release is where the last live build lives. This exists
so that if an absolutely critical issue arises, we can
make the fix here and release the build, being
confident that the ONLY change going out is the
critical bug fix.
Git more done
Git more done
Awesomest. Baby Bib. Ever.
Rebase vs. Merge (1)
โ€ข Merging brings two lines of development
together while preserving the ancestry of each
commit history.
โ€ข In contrast, rebasing unifies the lines of
development by re-writing changes from the
source branch so that they appear as children of
the destination branch โ€“ effectively pretending
that those commits were written on top of the
destination branch all along.
Play Doh
Rebase vs. Merge (2)
โ€ข Rebase requires the commits on the source
branch to be re-written, which changes their
content and their SHAS.
โ€ข Merging is better if you only have one (or few
trusted) commiter(s) and you donโ€Ÿt care much
about reading your history.
โ€ข Rebasing makes you sure that your commits go
on top of the โ€žpublicโ€Ÿ branch.

31
Commit graph (merge)
Commit graph (rebase)
Rebase vs. Merge (3)
โ€ข git merge <branch>
โ€“ Merge changes in the specified branch onto the current branch
โ€“ If you run into merge conflicts, the current branch is called local, and the
branch you are merging in is referred to as remote.

โ€ข git rebase <remote>/<branch>
โ€“ Base the current branch you are on off the specified remote branch
โ€“ Takes the specified branch as the base, and then applies any changes
you have in your local branch on top of that. For conflicts, the current
branch is called remote, and the branch you are rebasing off of is treated
as local.
โ€“ Example: git rebase origin/master
Merge
โ€ข Pros
โ€“ Simple to use and understand
โ€“ The commits on the source branch remain separate from
other branch commits, provided you donโ€Ÿt perform a fastforward merge. (This separation can be useful in the case
of feature branches, where you might want to take a
feature and merge it into another branch later.)
โ€“ Existing commits on the source branch are unchanged and
remain valid; it doesnโ€Ÿt matter if theyโ€Ÿve been shared.
โ€ข Cons
โ€“ If the need to merge arises simply because multiple people
are working on the same branch in parallel, the merges
donโ€Ÿt serve any useful historical purpose & create clutter.
Rebase
โ€ข Pros
โ€“ Simplifies your history.
โ€“ Is the most intuitive and clutter-free way to combine
commits from multiple developers in a shared branch.

โ€ข Cons
โ€“ Slightly more complex, conflicts require resolution on
a per commit basis.
โ€“ Rewriting of history has ramifications if youโ€Ÿve
previously pushed those commits elsewhere.
Golden Rule of Rebasing

โ€ข NEVER EVER rebase a branch
that you pushed, or that you
pulled from another person.

37
Git more done
Interactive Rebase (Squash)
โ€ข git rebase โ€“i HEAD~3
โ€“ pick f392171 Added new feature X
โ€“ pick ba9dd9a Added new elements to page design
โ€“ pick df71a27 Updated CSS for new elements

โ€ข Change to:
โ€“ pick f392171 Added new feature X
โ€“ squash ba9dd9a Added new elements to page
design
โ€“ squash df71a27 Updated CSS for new elements
Reflog, Detached Heads, Submodules
โ€ข Git reflog โ€“ โ€žrestore pointsโ€Ÿ for everything you do!
โ€ข Git reset โ€“hard <hash>
โ€ข Detached Head โ€“ Tracking a specific commit,
not a branch!
โ€ข Submodules โ€“ Shared โ€žchildโ€Ÿ git repository
(notorious for detached HEAD issuesโ€ฆ)
Resources
โ€ข Recommended
โ€“ http://rogerdudler.github.io/git-guide/
โ€“ http://www.slideshare.net/lemiorhan/git-branchingmodel?utm_source=slideshow&utm_medium=ssemail&utm_campaign=wee
kly_digest

โ€ข Comparison vs. SVN
โ€“
โ€“
โ€“
โ€“

http://whygitisbetterthanx.com/
http://git-scm.com/course/svn.html
https://git.wiki.kernel.org/index.php/GitSvnComparison
http://zurb.com/article/597/the-one-critical-reason-we-switched-from-

โ€ข Git Clients
โ€“ https://code.google.com/p/gitextensions/
โ€“ http://sourcetreeapp.com/
โ€“ https://github.com/dahlbyk/posh-git
Kwen Peterson
โ€ข http://tinyurl.com/rsdcc13
โ€“ https://github.com/Kwen/sdcc2013
โ€“ http://speakerrate.com/talks/27811-git-more-done
โ€“ http://www.slideshare.net/KwenPeterson/git-moredone

โ€ข
โ€ข
โ€ข
โ€ข

@kwenarik
#sdcc2013
plus.google.com/+KwenPeterson
kwen.peterson@gmail.com
https://github.com/Kwen
Ad

More Related Content

What's hot (20)

Version control
Version controlVersion control
Version control
visual28
ย 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
ย 
Git learning
Git learningGit learning
Git learning
Amit Gupta
ย 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
Thomas Rausch
ย 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
Tim Massey
ย 
From svn to git
From svn to gitFrom svn to git
From svn to git
Nehal Shah
ย 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentation
AyanaRukasar
ย 
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
Katie Sylor-Miller
ย 
Git basics
Git basicsGit basics
Git basics
GHARSALLAH Mohamed
ย 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Randal Schwartz
ย 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
Jim Yeh
ย 
Git training
Git trainingGit training
Git training
adm_exoplatform
ย 
GIT presentation
GIT presentationGIT presentation
GIT presentation
Naim Latifi
ย 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
Arnaud Seilles
ย 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
xSawyer
ย 
Git and GitHub
Git and GitHubGit and GitHub
Git and GitHub
Md. Ahsan Habib Nayan
ย 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
ย 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
ย 
Introduction git
Introduction gitIntroduction git
Introduction git
Dian Sigit Prastowo
ย 
Git from SVN
Git from SVNGit from SVN
Git from SVN
Justin Yoo
ย 
Version control
Version controlVersion control
Version control
visual28
ย 
An introduction to Git
An introduction to GitAn introduction to Git
An introduction to Git
Muhil Vannan
ย 
Git learning
Git learningGit learning
Git learning
Amit Gupta
ย 
Git Introduction Tutorial
Git Introduction TutorialGit Introduction Tutorial
Git Introduction Tutorial
Thomas Rausch
ย 
Subversion to Git Migration
Subversion to Git MigrationSubversion to Git Migration
Subversion to Git Migration
Tim Massey
ย 
From svn to git
From svn to gitFrom svn to git
From svn to git
Nehal Shah
ย 
Git hub ppt presentation
Git hub ppt presentationGit hub ppt presentation
Git hub ppt presentation
AyanaRukasar
ย 
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
Katie Sylor-Miller
ย 
Introduction to git
Introduction to gitIntroduction to git
Introduction to git
Randal Schwartz
ย 
Git tutorial II
Git tutorial IIGit tutorial II
Git tutorial II
Jim Yeh
ย 
GIT presentation
GIT presentationGIT presentation
GIT presentation
Naim Latifi
ย 
Introduction To Git
Introduction To GitIntroduction To Git
Introduction To Git
Arnaud Seilles
ย 
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
xSawyer
ย 
Git One Day Training Notes
Git One Day Training NotesGit One Day Training Notes
Git One Day Training Notes
glen_a_smith
ย 
Intro to git and git hub
Intro to git and git hubIntro to git and git hub
Intro to git and git hub
Venkat Malladi
ย 
Git from SVN
Git from SVNGit from SVN
Git from SVN
Justin Yoo
ย 

Similar to Git more done (20)

git.ppt.pdf
git.ppt.pdfgit.ppt.pdf
git.ppt.pdf
Roniel Lopez Alvarez
ย 
Git 101
Git 101Git 101
Git 101
jayrparro
ย 
GIT.pptx
GIT.pptxGIT.pptx
GIT.pptx
Soumen Debgupta
ย 
github ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know abgithub ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know ab
infoinnext
ย 
MakingGitWorkForYou
MakingGitWorkForYouMakingGitWorkForYou
MakingGitWorkForYou
Kwen Peterson
ย 
Git
GitGit
Git
Shinu Suresh
ย 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
Haitham Raik
ย 
git Technologies
git Technologiesgit Technologies
git Technologies
Hirantha Pradeep
ย 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Ahmed El-Arabawy
ย 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
ย 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
Peter Denev
ย 
SVN 2 Git
SVN 2 GitSVN 2 Git
SVN 2 Git
Marco De Stefano
ย 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Aidan Casey
ย 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Robert Lee-Cann
ย 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
Things Lab
ย 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
ย 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom
ย 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom
ย 
Learn Git Basics
Learn Git BasicsLearn Git Basics
Learn Git Basics
Prakash Dantuluri
ย 
Git 101
Git 101Git 101
Git 101
Sachet Mittal
ย 
Git 101
Git 101Git 101
Git 101
jayrparro
ย 
github ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know abgithub ppt git ppt on git hub to know ab
github ppt git ppt on git hub to know ab
infoinnext
ย 
MakingGitWorkForYou
MakingGitWorkForYouMakingGitWorkForYou
MakingGitWorkForYou
Kwen Peterson
ย 
GIT In Detail
GIT In DetailGIT In Detail
GIT In Detail
Haitham Raik
ย 
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Ahmed El-Arabawy
ย 
Introduction to Git and Github
Introduction to Git and Github Introduction to Git and Github
Introduction to Git and Github
Max Claus Nunes
ย 
GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016GIT_training_SoftServeBulgaria2016
GIT_training_SoftServeBulgaria2016
Peter Denev
ย 
Essential git for developers
Essential git for developersEssential git for developers
Essential git for developers
Aidan Casey
ย 
Beginner's Guide to Version Control with Git
Beginner's Guide to Version Control with GitBeginner's Guide to Version Control with Git
Beginner's Guide to Version Control with Git
Robert Lee-Cann
ย 
Source Code Management with Git
Source Code Management with GitSource Code Management with Git
Source Code Management with Git
Things Lab
ย 
Git cheat sheet__grey
Git cheat sheet__greyGit cheat sheet__grey
Git cheat sheet__grey
King Hom
ย 
Git cheat sheet__white
Git cheat sheet__whiteGit cheat sheet__white
Git cheat sheet__white
King Hom
ย 
Git cheat sheet_dark
Git cheat sheet_darkGit cheat sheet_dark
Git cheat sheet_dark
King Hom
ย 
Ad

Recently uploaded (20)

How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
Salesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docxSalesforce AI Associate 2 of 2 Certification.docx
Salesforce AI Associate 2 of 2 Certification.docx
Josรฉ Enrique Lรณpez Rivera
ย 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?How Can I use the AI Hype in my Business Context?
How Can I use the AI Hype in my Business Context?
Daniel Lehner
ย 
Technology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data AnalyticsTechnology Trends in 2025: AI and Big Data Analytics
Technology Trends in 2025: AI and Big Data Analytics
InData Labs
ย 
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdfComplete Guide to Advanced Logistics Management Software in Riyadh.pdf
Complete Guide to Advanced Logistics Management Software in Riyadh.pdf
Software Company
ย 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
ย 
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
AI Changes Everything โ€“ Talk at Cardiff Metropolitan University, 29th April 2...
Alan Dix
ย 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
ย 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
ย 
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc Webinar: Consumer Expectations vs Corporate Realities on Data Broker...
TrustArc
ย 
Role of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered ManufacturingRole of Data Annotation Services in AI-Powered Manufacturing
Role of Data Annotation Services in AI-Powered Manufacturing
Andrew Leo
ย 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
ย 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
ย 
Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)Into The Box Conference Keynote Day 1 (ITB2025)
Into The Box Conference Keynote Day 1 (ITB2025)
Ortus Solutions, Corp
ย 
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your UsersAutomation Dreamin' 2022: Sharing Some Gratitude with Your Users
Automation Dreamin' 2022: Sharing Some Gratitude with Your Users
Lynda Kane
ย 
Mobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi ArabiaMobile App Development Company in Saudi Arabia
Mobile App Development Company in Saudi Arabia
Steve Jonas
ย 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
ย 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
ย 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
ย 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
ย 
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In FranceManifest Pre-Seed Update | A Humanoid OEM Deeptech In France
Manifest Pre-Seed Update | A Humanoid OEM Deeptech In France
chb3
ย 
Ad

Git more done

  • 1. git more done Kwen Peterson Senior Software Developer @ Raven [email protected] @kwenarik
  • 2. "You're already in the top tier of developers just by showing up here tonight. I don't know how talented you are, how much experience you have, but you showed up. You're putting yourself out there because you care to improve. Thanks for caring.โ€œ โ€“ Scott Hanselman
  • 3. Distributed โ€ข One of the coolest features of any of the Distributed VCSs, Git included, is that it isnโ€Ÿt centralized. โ€“ This means that even if you're using a centralized workflow, every user has what is essentially a full backup of the main server, each of which could be pushed up to replace the main server in the event of a crash or corruption. โ€“ There is basically no single point of failure with a distributed VCS.
  • 4. Git is Fast โ€ข Git is extremely fast. Since all operations (except for push and fetch) are local there is no network latency involved to: โ€“ โ€“ โ€“ โ€“ โ€“ Perform a diff. View file history. Commit changes. Merge branches. Obtain any other revision of a file (not just the prior committed revision). โ€“ Switch branches.
  • 5. Git is orders of magnitude faster than SVN. Operation Git SVN Speed Commit Files (A) 0.64 2.60 4x Commit Images (B) 1.53 24.70 16x Diff Current 0.25 1.09 4x Diff Recent 0.25 3.99 16x Diff Tags 1.17 83.57 71x Log (50) 0.01 0.38 31x Log (All) 0.52 169.20 325x Log (File) 0.60 82.84 138x Update 0.90 2.82 3x Blame 1.91 3.04 1x
  • 6. Git is Small โ€ข Git's repository and working directory sizes are extremely small when compared to SVN. โ€“ The Mozilla repository is reported to be almost 12 Gb stored across 240,000 files in SVN. โ€“ The exact same history is stored in Git using two files totaling just over 420 Mb. โ€ข This means that SVN requires 30x the disk space to store the same history! โ€“ One of the reasons for the smaller repo size is that an SVN working directory always contains two copies of each file: one for the user to actually work with and another hidden in .svn/ to aid operations such as status, diff and commit. โ€“ In contrast a Git working directory requires only one small index file that stores about 100 bytes of data per tracked file. On projects with a large number of files this can be a substantial difference in the disk space required per working copy.
  • 7. Git is * โ€ข GitHub โ€“ 3 million+ users โ€“ 5 million+ repositories โ€“ THE place for open-source projects โ€ข Merging & Branching are easy โ€“ (unlike in many centralized systems)
  • 8. The branch Dilemma I have a 120 hour work package to do! SVN: โ€“ sit on 3 weeks worth of changes unversioned and then finally push 1 massive commit? โ€“ push updates to trunk/branch as necessary and possibly break functionality for anyone else working on project (but get to keep commit history, and not have 1 massive commit) Git: โ€“ make daily commits to my local branch (full history, able to rollback to intermediate stages!) โ€“ merge in changes that others have pushed to the master branch at my convenience โ€“ hold off pushing to master until my code is fully polished and tested out, minimizing impact on other developers
  • 9. Code Reviews โ€ข SVN โ€“ Make a patch of uncommitted changes and send it to another developer, and hope that they have an SVN branch at the exact commit as yours to apply it to. โ€ข Git โ€“ Push a copy of your local branch (and all its commits) out to a remote branch on a repository, where anyone can easily pull down a copy and build your code, no matter where there current branch is.
  • 10. git-svn โ€ข โ€œGit is the best SVN client out there.โ€ โ€“ Keith Dahlby โ€ข Gives you ALL the local repository benefits of git, while letting you treat your SVN repo as โ€žjust another remoteโ€Ÿ
  • 15. Creating a Repository โ€ข git init โ€“ Creates an empty repository at current location โ€ข git clone <url> โ€“ Creates a local copy of an existing repository โ€“ Examples: โ€ข git clone http://github.com/jquery/jquery.git
  • 16. Working with Remotes โ€ข git remote add <name> <url> โ€“ Maps a remote โ€“ Example: git remote kwen git://source/kwen-test.git โ€ข git remote show <name> โ€“ Displays a list of branches on the remote, any local branches that track them, fetch URL, etc. โ€ข git remote rm <name> โ€ข git remote rename <old> <new>
  • 17. Working with Branches โ€ข git checkout <branch> โ€“ Change to the specified local branch โ€ข git branch <name> <remote>/<branch> โ€“ Create a local branch that tracks the remote branch โ€“ Example: git branch milestone3 kwen-test/milestone3 โ€ข git checkout โ€“b <name> <remote>/<branch> โ€“ Creates a new local branch and immediately checks it out โ€“ Example: git co โ€“b codereview kwen-test/milestone4
  • 18. Dealing with Changes โ€ข git st โ€“ Shows you the status of currently modified files (tracked & untracked) โ€ข git add <file> (use a gui instead!) โ€“ adds the specified file to the list of tracked changes โ€ข git commit โ€“m <message> (use a gui instead!) โ€“ Commits all tracked changes to the current branch โ€ข git reset HEAD โ€“hard โ€“ Reset current branch and lose ALL changes โ€ข git stash <tag> โ€“ Store all current changes away temporarily โ€“ The tag is optional, and it will generate one for you if not provided โ€ข git stash apply <tag> โ€“ Reapply the last set of stashed changes onto the current branch
  • 19. Pushing and Pulling Changes โ€ข git fetch <name> โ€“ Gets the latest updates from the remote, but does NOT apply them โ€“ Example: git fetch origin โ€ข git pull <remote> <branch> โ€“ Runs git fetch and then git merge โ€“ If you are on a branch that already tracks a remote, you can just use git pull, and it will merge any updates in the tracked remote branch into your local branch. โ€“ Can pass a --rebase parameter to rebase instead of merge โ€ข git push <remote> <name>:<branch> โ€“ Pushes the updates in my current local branch out to a remote branch โ€“ Example: git push origin milestone3:milestone3
  • 20. Git Trivia 1. Git push origin master:master 2. Git push origin +master:master 3. Git push origin โ€“f master:master
  • 21. Creating & Applying Patches โ€ข git format-patch <branch> โ€“ Creates patches for the diff between the current branch & <branch> โ€“ Example: My local dev branch has updates that have not been committed to origin/dev yet, but that I need to send to Wes. Running git format-patch origin/dev creates patches for each of the commits that are on my local dev branch that are not in origin/dev. โ€ข git format-patch -# โ€“ Same as above, except this method simply takes the last X commits and creates patches for them. โ€“ Example: git format-patch -3 (creates patches for the last 3 commits you made on this branch) โ€ข git am -3 โ€“s โ€“i <file or folder> โ€“ Apply the specified patches to the current branch โ€“ Example: git am -3 โ€“s โ€“i patches/* (applies all the patches located in my patches folder)
  • 22. Copy/Paste a commit locally โ€ข Git cherry-pick <hash> โ€“ Copies the changeset for the given commit onto the current branch โ€“ (Great way to apply a hotfix to multiple different branches.) *
  • 25. Common git branching strategy โ€ข 3 core branches: master, dev, release โ€“ Master is โ€œthe truthโ€ and should always be in a stable, fully-functional state. This is where new topic/feature branches are cloned from. (nightly builds) โ€“ Dev is where integration testing happens. This is where topic branches are pushed and tested PRIOR to being signed off on as stable enough to go to master. (continuous integration, test environment) โ€“ Release is where the last live build lives. This exists so that if an absolutely critical issue arises, we can make the fix here and release the build, being confident that the ONLY change going out is the critical bug fix.
  • 29. Rebase vs. Merge (1) โ€ข Merging brings two lines of development together while preserving the ancestry of each commit history. โ€ข In contrast, rebasing unifies the lines of development by re-writing changes from the source branch so that they appear as children of the destination branch โ€“ effectively pretending that those commits were written on top of the destination branch all along.
  • 31. Rebase vs. Merge (2) โ€ข Rebase requires the commits on the source branch to be re-written, which changes their content and their SHAS. โ€ข Merging is better if you only have one (or few trusted) commiter(s) and you donโ€Ÿt care much about reading your history. โ€ข Rebasing makes you sure that your commits go on top of the โ€žpublicโ€Ÿ branch. 31
  • 34. Rebase vs. Merge (3) โ€ข git merge <branch> โ€“ Merge changes in the specified branch onto the current branch โ€“ If you run into merge conflicts, the current branch is called local, and the branch you are merging in is referred to as remote. โ€ข git rebase <remote>/<branch> โ€“ Base the current branch you are on off the specified remote branch โ€“ Takes the specified branch as the base, and then applies any changes you have in your local branch on top of that. For conflicts, the current branch is called remote, and the branch you are rebasing off of is treated as local. โ€“ Example: git rebase origin/master
  • 35. Merge โ€ข Pros โ€“ Simple to use and understand โ€“ The commits on the source branch remain separate from other branch commits, provided you donโ€Ÿt perform a fastforward merge. (This separation can be useful in the case of feature branches, where you might want to take a feature and merge it into another branch later.) โ€“ Existing commits on the source branch are unchanged and remain valid; it doesnโ€Ÿt matter if theyโ€Ÿve been shared. โ€ข Cons โ€“ If the need to merge arises simply because multiple people are working on the same branch in parallel, the merges donโ€Ÿt serve any useful historical purpose & create clutter.
  • 36. Rebase โ€ข Pros โ€“ Simplifies your history. โ€“ Is the most intuitive and clutter-free way to combine commits from multiple developers in a shared branch. โ€ข Cons โ€“ Slightly more complex, conflicts require resolution on a per commit basis. โ€“ Rewriting of history has ramifications if youโ€Ÿve previously pushed those commits elsewhere.
  • 37. Golden Rule of Rebasing โ€ข NEVER EVER rebase a branch that you pushed, or that you pulled from another person. 37
  • 39. Interactive Rebase (Squash) โ€ข git rebase โ€“i HEAD~3 โ€“ pick f392171 Added new feature X โ€“ pick ba9dd9a Added new elements to page design โ€“ pick df71a27 Updated CSS for new elements โ€ข Change to: โ€“ pick f392171 Added new feature X โ€“ squash ba9dd9a Added new elements to page design โ€“ squash df71a27 Updated CSS for new elements
  • 40. Reflog, Detached Heads, Submodules โ€ข Git reflog โ€“ โ€žrestore pointsโ€Ÿ for everything you do! โ€ข Git reset โ€“hard <hash> โ€ข Detached Head โ€“ Tracking a specific commit, not a branch! โ€ข Submodules โ€“ Shared โ€žchildโ€Ÿ git repository (notorious for detached HEAD issuesโ€ฆ)
  • 41. Resources โ€ข Recommended โ€“ http://rogerdudler.github.io/git-guide/ โ€“ http://www.slideshare.net/lemiorhan/git-branchingmodel?utm_source=slideshow&utm_medium=ssemail&utm_campaign=wee kly_digest โ€ข Comparison vs. SVN โ€“ โ€“ โ€“ โ€“ http://whygitisbetterthanx.com/ http://git-scm.com/course/svn.html https://git.wiki.kernel.org/index.php/GitSvnComparison http://zurb.com/article/597/the-one-critical-reason-we-switched-from- โ€ข Git Clients โ€“ https://code.google.com/p/gitextensions/ โ€“ http://sourcetreeapp.com/ โ€“ https://github.com/dahlbyk/posh-git
  • 42. Kwen Peterson โ€ข http://tinyurl.com/rsdcc13 โ€“ https://github.com/Kwen/sdcc2013 โ€“ http://speakerrate.com/talks/27811-git-more-done โ€“ http://www.slideshare.net/KwenPeterson/git-moredone โ€ข โ€ข โ€ข โ€ข @kwenarik #sdcc2013 plus.google.com/+KwenPeterson [email protected] https://github.com/Kwen