SlideShare uma empresa Scribd logo
1 de 95
Github for the Rest of Us
or: how i learned to stop worrying
and love version control
by Morten Rand-Hendriksen
!@MOR10
http://www.xkcd.com/1597/
SOLVES EVERYTHING
Say you find yourself
in space
On a ship hauling
valuable materials
from an astroid.
And there’s a huge
hole in your oxygen
supply.
You could go outside
and fix it, but theres a
big crack in your
jetpack as well.
If you don’t do
something, your
oxygen will run out.
And if that wasn’t bad
enough,
The only patch kit on
the ship is outside, on
the hull.
But to patch both the
jetpack and the
oxygen tank, you
need TWO patch kits.
This is one of those
times when a cloning
machine would come
in real handy.
But here’s the thing.
We actually have a
cloning machine.
And it can do a lot
more than just clone.
It can also help us
travel through time!
First thing’s first:
Before you do
anything else, you
need to commit the
current state to
memory, sort of like
a save point in a
game.
This first commit
becomes an anchor
point in time you can
always go back to.
git checkout -b get_patch_kit
Then, you can create
an alternate timeline
and jump to it.
Now, in that alternate
timeline, you can start
experimenting:
To patch the air leak, you
have to get the patch kit
outside the ship. So let’s
see if you can just jump
outside and grab it
without the spacesuit.
release the airlock
and
PWHOSHHHHH
Get ejected into
space…
… to float around
for eternity as a
piece of frozen
space junk.
OK, so that
didn’t work.
Doesn’t matter.
You’re on an
alternate timeline,
so you can just jump
back in time to the
original commit and
start over!
git checkout -b get_patch_kit_secure
Let’s try that again.
Make a new
alternate timeline,
and this time take
some precautions.
Before releasing the
airlock, you tether
yourself to the ship
so when the air
rushes out, you
won’t just get
ejected
Swing yourself out
of the airlock and
grab the patch kit…
… stuff it in your
giant spacesuit
kangaroo pocket…
… and drift into
space like a frozen
piece of space junk.
Only this time, you
have the patch kit!
git checkout master
You see now you
can travel back in
time …
… to before you
went outside the
ship …
… hit the
“Merge” button …
git merge --no-ff get_patch_kit_secure
…and merge the
two timelines
together!
When the timelines
merge, the patch
kit from the timeline
where you picked it
up becomes part of
the current timeline.
Now you can patch
your jetpack …
… put on your
spacesuit …
git commit -m “going outside”
… commit a new
save point …
… cycle through
the airlock …
… and grab the
patch kit from the
outside (because
we are now on the
original timeline
where we have yet
to use it).
git checkout -b repair_tanks
Create a new
alternate timeline
for the tank repair
…
… and start
repairing the tank.
But there’s a
problem! The patch
kit is only enough
to repair half the
leak!
git commit -m “patch 50% complete”
Not a problem.
Simply commit the
current 50%
complete patch …
git checkout master
Jump back in time
to when you first
picked up the patch
kit.
git merge --no-ff repair_tanks
Merge the 50%
patch to the current
timeline.
Now the leak is
half resolved.
git checkout -b repair_tanks_v2git checkout -b repair_tanks_v2
To fix the rest of the
leak, you have to
go back in time to
before you picked
up the patch kit …
git checkout -b repair_tanks_v2git checkout going_outside
… create a new
branch from the
main timeline,
where the patch kit
has not yet been
used …
… cycle through
the airlock …
… and grab the
patch kit from the
outside (because
we are now on a
new timeline where
we have yet to use
it).
Go back and patch
the tank from the
other side.
Now you have a
patch that covers
the other 50% of
the leak.
git commit -m “other 50% patched.
possible conflict”
Commit a new save
point for the other
50% patch.
git checkout master
Checkout the
previous merge
point …
Hit the merge
button again …
git merge --no-ff repair_tank_v2
… and merge the
new patch to the
main timeline.
But there’s a
conflict!
The two patches
overlap and a
merge can’t be
completed.
To resolve the
conflict, go back
outside…
… identify the
conflict …
… and resolve it by
changing one of
the patches to
remove the
overlap.
git commit -m “patch conflict resolved”
Now you can
commit the final
merge which serves
as the save point
for the finished
patch. And that’s it!
Problem solved!
Except when you
move to take your
spacesuit off, an
alarm sounds!
And your friendly
AI gives you the
most confusing
message:
“Are you sure you
want to do that?”
OK, so obviously
something is
wrong, but what?
Glancing over at
the oxygen meter,
you see the
problem. While
you’ve been
patching the leak,
all the oxygen has
disappeared.
git checkout “first commit”
Not a problem! Just
checkout the first
commit …
… back when the
oxygen leak had
just started …
… and the oxygen
supply was still at
70% …
git checkout -b air_supply
Create a new
branch called
“air_supply” …
git commit -m “making love out of
nothing at all”
… commit a new
save point with our
70% full air tank …
git rebase master
… and rewrite
history by rebasing
the new save point
to the top of our
current timeline.
Using Git, we’ve used the same patch kit
three times to fix the jetpack and the air leak
(twice), and borrowed an air supply from
the past to top off our tanks.
SOLVES EVERYTHING
SOLVES EVERYTHING
on your computer
in the cloud
REPOSITORY
The universe in which your
project exists.
git commit
Create a snapshot, or save
point, to which you can
always return.
Commits
git branch
An alternate timeline within
the current universe.
Branches
git checkout
Your personal time machine.
Checkout allows you to jump
to any commit on any branch,
in your current universe or any
other universe.
git merge
Merge the contents of one
timeline into another.
CONFLICT
Changes have taken place in
both both timelines after they
were split apart. You must
decide what change to keep
and what change to discard.
git rebase
Rewrite history by tacking the
events of one timeline onto
another as if they were always
there.
git rebase
Rewrite history by tacking the
events of one timeline onto
another as if they were always
there.
git fork
An alternate universe that
starts as an exact copy of the
one you forked.
git clone
Make a duplicate copy of an
external universe and place it
in the current one.
Empty repo
git clone
Make a duplicate copy of an
external universe and place it
in the current one.
Clone
git push
Physically push your commits
to another repository
(typically Github)
Push
Local
Remote
git fetch
Grab the current version of an
external timeline and open it.
Local
Remote
Fetch
git pull
Grab the current version of an
external timeline and merge it
with the current timeline.
Local
Remote
Pull
DETACHED HEAD
Before using the time machine,
changes were made without
being committed, thereby
detaching them. Create a new
timeline to restore reality.
Uncommitted
change
DETACHED HEAD
Before using the time machine,
changes were made without
being committed, thereby
detaching them. Create a new
timeline to restore reality.
Checkout
DETACHED HEAD
Before using the time machine,
changes were made without
being committed, thereby
detaching them. Create a new
timeline to restore reality.
Detached
head
DETACHED HEAD
Before using the time machine,
changes were made without
being committed, thereby
detaching them. Create a new
timeline to restore reality.
Fix with
new branch
Don’t let the command line deter you.
There are better options!
desktop.github.com
sourcetreeapp.com
SOLVES EVERYTHING
Get a free 10-day trial:
lynda.com/trial/mor10

Mais conteúdo relacionado

Destaque

Antoine Savary
Antoine SavaryAntoine Savary
Antoine SavaryGOPAcom
 
Rachelle+Resume+2--gd-1-1
Rachelle+Resume+2--gd-1-1Rachelle+Resume+2--gd-1-1
Rachelle+Resume+2--gd-1-1RACHELLE POWERS
 
SAK Työympäristöseminaari 17 10 15 FINAL
SAK Työympäristöseminaari 17 10 15 FINALSAK Työympäristöseminaari 17 10 15 FINAL
SAK Työympäristöseminaari 17 10 15 FINALAntti Koivula
 
GitHub for People Who Don't Code
GitHub for People Who Don't CodeGitHub for People Who Don't Code
GitHub for People Who Don't CodeChristopher Schmitt
 
Fatigue in football players due to misuse of sport drinks
Fatigue in football players due to misuse of sport drinksFatigue in football players due to misuse of sport drinks
Fatigue in football players due to misuse of sport drinksMiguel Cabezas Andreu
 
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.Michael Koenka
 

Destaque (8)

Antoine Savary
Antoine SavaryAntoine Savary
Antoine Savary
 
Rachelle+Resume+2--gd-1-1
Rachelle+Resume+2--gd-1-1Rachelle+Resume+2--gd-1-1
Rachelle+Resume+2--gd-1-1
 
muni resume (1)
muni resume (1)muni resume (1)
muni resume (1)
 
SAK Työympäristöseminaari 17 10 15 FINAL
SAK Työympäristöseminaari 17 10 15 FINALSAK Työympäristöseminaari 17 10 15 FINAL
SAK Työympäristöseminaari 17 10 15 FINAL
 
Ce este Jurnalul IMPACT?
Ce este Jurnalul IMPACT?Ce este Jurnalul IMPACT?
Ce este Jurnalul IMPACT?
 
GitHub for People Who Don't Code
GitHub for People Who Don't CodeGitHub for People Who Don't Code
GitHub for People Who Don't Code
 
Fatigue in football players due to misuse of sport drinks
Fatigue in football players due to misuse of sport drinksFatigue in football players due to misuse of sport drinks
Fatigue in football players due to misuse of sport drinks
 
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.
Pitch Like a Boss: Talk to Anyone, Anytime, Anywhere.
 

Mais de Morten Rand-Hendriksen

Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Morten Rand-Hendriksen
 
How Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyHow Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyMorten Rand-Hendriksen
 
How to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignHow to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignMorten Rand-Hendriksen
 
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Morten Rand-Hendriksen
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017Morten Rand-Hendriksen
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017Morten Rand-Hendriksen
 
Empathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityEmpathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityMorten Rand-Hendriksen
 
Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Morten Rand-Hendriksen
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noMorten Rand-Hendriksen
 
Your Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckYour Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckMorten Rand-Hendriksen
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your SiteMorten Rand-Hendriksen
 

Mais de Morten Rand-Hendriksen (14)

How to Build Custom WordPress Blocks
How to Build Custom WordPress BlocksHow to Build Custom WordPress Blocks
How to Build Custom WordPress Blocks
 
Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0Building the next generation of themes with WP Rig 2.0
Building the next generation of themes with WP Rig 2.0
 
How Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and TechnologyHow Not to Destroy the World: Ethics in Design and Technology
How Not to Destroy the World: Ethics in Design and Technology
 
How to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web DesignHow to Not Destroy the World - the Ethics of Web Design
How to Not Destroy the World - the Ethics of Web Design
 
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
Gutenberg and the WordPress of Tomorrow - WordCamp US 2017
 
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
CSS Grid Changes Everything - Keynote at WebCamp Zagreb 2017
 
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
CSS Grid Changes Everything About Web Layouts: WordCamp Europe 2017
 
Empathy and Acceptance in Design and Community
Empathy and Acceptance in Design and CommunityEmpathy and Acceptance in Design and Community
Empathy and Acceptance in Design and Community
 
Ethics and the Promise of Open Source
Ethics and the Promise of Open SourceEthics and the Promise of Open Source
Ethics and the Promise of Open Source
 
Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015Responsive Images in the Real World - presented at JavaScript Open 2015
Responsive Images in the Real World - presented at JavaScript Open 2015
 
Can WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.noCan WordPress really do that? A case study of vierderduer.no
Can WordPress really do that? A case study of vierderduer.no
 
Your Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos SuckYour Blog is Boring and Your Photos Suck
Your Blog is Boring and Your Photos Suck
 
Wp meetup custom post types
Wp meetup custom post typesWp meetup custom post types
Wp meetup custom post types
 
10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site10 WordPress Theme Hacks to Improve Your Site
10 WordPress Theme Hacks to Improve Your Site
 

Último

TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSedrianrheine
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...APNIC
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteMavein
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Shubham Pant
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdfShreedeep Rayamajhi
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024Jan Löffler
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpressssuser166378
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxnaveenithkrishnan
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilitiesalihassaah1994
 
Niche Domination Prodigy Review Plus Bonus
Niche Domination Prodigy Review Plus BonusNiche Domination Prodigy Review Plus Bonus
Niche Domination Prodigy Review Plus BonusSkylark Nobin
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSlesteraporado16
 
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfmchristianalwyn
 
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptx
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptxA_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptx
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptxjayshuklatrainer
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsRoxana Stingu
 
world Tuberculosis day ppt 25-3-2024.pptx
world Tuberculosis day ppt 25-3-2024.pptxworld Tuberculosis day ppt 25-3-2024.pptx
world Tuberculosis day ppt 25-3-2024.pptxnaveenithkrishnan
 

Último (15)

TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDSTYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
TYPES AND DEFINITION OF ONLINE CRIMES AND HAZARDS
 
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
Benefits of doing Internet peering and running an Internet Exchange (IX) pres...
 
Computer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a WebsiteComputer 10 Lesson 8: Building a Website
Computer 10 Lesson 8: Building a Website
 
Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024Check out the Free Landing Page Hosting in 2024
Check out the Free Landing Page Hosting in 2024
 
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdfIntroduction to ICANN and Fellowship program  by Shreedeep Rayamajhi.pdf
Introduction to ICANN and Fellowship program by Shreedeep Rayamajhi.pdf
 
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
WordPress by the numbers - Jan Loeffler, CTO WebPros, CloudFest 2024
 
Presentation2.pptx - JoyPress Wordpress
Presentation2.pptx -  JoyPress WordpressPresentation2.pptx -  JoyPress Wordpress
Presentation2.pptx - JoyPress Wordpress
 
Bio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptxBio Medical Waste Management Guideliness 2023 ppt.pptx
Bio Medical Waste Management Guideliness 2023 ppt.pptx
 
Zero-day Vulnerabilities
Zero-day VulnerabilitiesZero-day Vulnerabilities
Zero-day Vulnerabilities
 
Niche Domination Prodigy Review Plus Bonus
Niche Domination Prodigy Review Plus BonusNiche Domination Prodigy Review Plus Bonus
Niche Domination Prodigy Review Plus Bonus
 
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASSLESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
LESSON 10/ GROUP 10/ ST. THOMAS AQUINASS
 
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdfLESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
LESSON 5 GROUP 10 ST. THOMAS AQUINAS.pdf
 
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptx
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptxA_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptx
A_Z-1_0_4T_00A-EN_U-Po_w_erPoint_06.pptx
 
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced HorizonsVision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
Vision Forward: Tracing Image Search SEO From Its Roots To AI-Enhanced Horizons
 
world Tuberculosis day ppt 25-3-2024.pptx
world Tuberculosis day ppt 25-3-2024.pptxworld Tuberculosis day ppt 25-3-2024.pptx
world Tuberculosis day ppt 25-3-2024.pptx
 

GitHub for the Rest of Us