►
Description
Hector Alfaro, trainer at GitHub, searched the world over for the gnarliest, most terrifying git scenarios he could find. In this session, he'll teach us how to use some of the more advanced porcelain commands to detangle all the things and become a git hero or heroine.
About GitMerge
Git Merge is the pre-eminent Git-focused conference: a full-day offering technical content and user case studies, plus a day of workshops for Git users of all levels. Git Merge is dedicated to amplifying new voices in the Git community and to showcasing the most thought-provoking projects from contributors, maintainers and community managers around the world. Find out more at git-merge.com
A
So
learning
it
is
hard
and
as
a
trainer
for
github
I
can
kind
of
give
you
a
testament
to
that.
It's
it's
one
thing
to
be
able
to
use
git,
it's
quite
another
to
teach
it
to
somebody
else.
So
it's
an
interesting
thing
that
I
encounter
every
day
that
I
go
out
and
I
teach
a
class
on
game.
So
let
me
ask
you
this
follow-up
question
is:
who
has
had
the
opportunity
to
teach
get
to
somebody
else.
Raise
your
hand
if
you
talk
it
to
somebody
else,
okay,
leave
your
hand
raised.
A
If
you
were
successful,
if
you
think
you
were
successful,
awesome
alright,
good!
So
a
lot
of
the
anxiety
that
I
that
I
encounter
from
folks
that
are
learning
how
to
use
git,
it's
from
the
fear
that
they're
getting
themselves
into
a
situation
that
they
can't
get
themselves
out
of.
So
what
I
thought
we'd
do
in
this
session
is
highlight
some
pretty
gnarly,
but
not
too
far
off
scenarios
that
you
or
your
students
might
find
themselves
into
so
that
you
can
see
it's
possible
to
get
out
of
pretty
much
anything
using
git.
A
A
A
And
so
what
I've
done
in
this
particular
repo
here
is
I've
crafted
a
story
modeled
after
Alexander
and
the
terrible
no-good
horrible
very
bad
day.
I
think
I
got
that
out
of
order.
Who's
read
that
book
before.
Perhaps
if
you
have
kids
or
okay,
it's
a
small
group,
so
this
will
be
an
interesting
practice.
That's
what
that's
all
right
so
I've!
This
repo
is
just
the
story
crafted
after
Alexander
and
a
terrible,
no
good,
very
bad
horrible
day,
I'm
pretty
sure
I'm
mixing
that
up.
A
A
So
the
first
thing
we'll
talk
about
is
how
to
find
naughty
commits
with
git
bisect.
Sometimes
we
know
there's
a
commit,
that's
broken
our
build,
but
we
can't
place
our
finger
on
which
commit
is
naughty
or
perhaps
our
history
is
too
massive
to
sort
through
hundreds
of
commits
so
get.
Bisect
is
one
way
that
we
can
find
those
naughty
commits
using
a
simple
binary
search.
A
So
that's
precisely
what
happened
in
my
repo.
So
if
you
look
at
my
log
here,
there's
commit
a
five,
a
1/5
de
and
that's
a
commit
that
I
added
a
section
about
the
FG
to
my
story
and
then
so.
Bfg
is
an
alternate
to
get
such
a
branch,
and
so,
let's
just
say
for
the
sake
of
argument
that
I
wanted
to
exclude
that
particular
section.
From
my
talk.
Let's
say
that
I
didn't
have
enough
time
to
talk
about
BFG,
so
I
wanted
to
find
a
commit
that
introduced
PFD.
A
So
in
this
particular
case
that
commit
is
nicely
labeled.
But
let's
we're
working
under
the
assumption
that
it's
not
always
nicely
labeled.
So
the
way
we
start
a
get
bisect
is
with
git
bisect
start,
and
then
you
have
to
tell
git
where
you
first
notice
the
problem.
So
that's
why
we
see
good
bisect,
bad
and
I'm
just
going
to
point
to
my
head
commit
there
and
then,
where
your
repo
was
last
in
good
shape,
so
in
my
case
I'm
going
to
go
ahead
and
do
a
git
bisect
good.
A
My
repo
was
in
good
shape
over
in
the
starting
commit
the
very
first
to
make
the
winning
so
git
bisect
start
will
get
me
started,
get
bisect
that
will
point
to
the
commit
that
has
a
bug
in
it
and
then
get
bisect
good
will
point
to
a
commit
that
I
know
is
good,
and
so
what
then
get
is
going
to
do?
Is
it's
going
through
one?
A
So
in
my
particular
repo,
what
I'm
doing
is
I'm
looking
for
a
mention
of
BFG
within
my
repo,
so
this
particular
commit
that
I'm
looking
at
here
does
it
have
a
mention
of
DFG,
so
I'm
going
ahead
and
labeling
that
as
advice,
a
good
so
since
that
commit
is
good.
What's
happening?
Is
my
history
from
that
point
on
it's
going
to
be
considered
good,
so
we're
going
to
be
starting
to
start
looking
at
the
bad
history,
which
is
the
other
half
of
history.
A
Take
a
look
at
my
file
here,
so
I
was
checked
out
to
a
different
commit
here
in
that
committed
particular,
there
is
a
reference
to
BFG
there,
so
we're
going
to
label
that
as
a
bad
commit.
So
we
do
you
get
bisects
bad
on
that
particular
commit
get
once
again
check
me
out
to
a
different
commit
about
halfway
through
the
history
and
that
commit
in
particular,
doesn't
happy
FGM,
so
I'm
going
to
label,
let
us
get
bisected,
and
so
what
I'm
left
with
here
is
I'm
left
with
the
commit
that
is
the
offending
committed.
A
A
So,
but
before
I
go
on,
all
I
need
to
do
is
I
need
to
reset
back
to
the
master
branch,
because
I'm
left
in
this
state,
where
bisect
has
divided
my
history
and
checked
me
out
to
Prior,
commits
within
that
history,
so
goodbye,
sorry
set
gets
by
sickly.
So
that
just
gets
you
back
to
your
master
branch.
A
So
now
that
we've
found
our
offending
commit
I
want
to
make
sure
that
it
is
indeed
a
naughty
commit
and
then
I
want
to
revert
it
so
revert
so
fairly
safe
command
right.
The
revert
doesn't
alter
our
history
in
any
way.
Our
previous
history
is
additive.
It
adds
to
our
history,
so
the
first
thing
we'll
do
is
we
want
to
look
at
that
offending
commit
to
make
sure
it
does
indeed
contain
a
reference
to
BFG,
so
I'll
just
run
a
good
show
on
that
commit
and
I'll
see
that
that
commit
introduces
the
BFG
line.
A
So
we're
now
ready
to
perform
that
revert,
so
we've
used
git
bisect
to
find
the
offending
commit.
We've
then
used
good
show
and
get
diff
to
make
sure
that
it
does
indeed
contain
some
content
that
in
this
particular
case
we
don't
want,
and
what
we'll
do
is
we'll
go
ahead
and
revert
that
commit
so
we'll
do
that
with
git
revert
and
as
I
mentioned
before
revert
is
a
fairly
safe
operation.
It
adds
to
our
history,
doesn't
alter
our
history
in
any
way
our
previous
history
in
any
way.
A
A
A
And
then
we
can
run
get
this
or,
in
this
particular
case,
get
this
space
because
we
have
staged
the
the
resolution
already
so
we'll
run
get
this
stage
to
take
a
look
at
what
this
particular
revert
does
and
this
particular
case
the
revert
removes
the
offending
line.
So
just
to
recap,
we've
used
git
bisect
to
find
the
commit
that
introduced.
A
A
A
And
then
get
is
just
asking
us
to
input
that
last
commit
message
in
this
case
that
commit
message
for
the
revert
which
I
am
happy
with
the
default
message.
So
I'm
going
to
keep
that,
and
we
can
take
a
look
at
our
history
here,
so
just
how
we
expected
all
this
adds
is
a
new
commit
in
this
case
III
for
2
and
E
3,
for
in
my
case,
is
just
the
inverse
of
that
of
that
commit
that
asked
BFG
to
my
story.
A
A
A
A
A
So
the
first
thing
we'll
do
is
we'll
create
a
branch
and
I'll
call.
This
branch
remove
the
FG,
and
so
the
next
thing
we're
going
to
do
after
that
is
we're
going
to
either
reset
command,
because
we're
on
the
master
branch
which
we
said
is
going
to
do,
is
it's
going
to
pick
up
head
and
it's
going
to
reset
head
to
a
previous
commit
in
history.
A
In
our
case,
we're
going
to
reset
head
back
one
jump
in
history,
so
we're
going
to
go
back
to
C
to
EB,
but
now
that's
because
we're
on
the
master
branch
on
the
remove
BFD
BFD
branch.
We're
still
going
to
have
this
history
here.
So
that's
going
to
give
us
the
effect
we're
looking
for,
which
is
to
have
the
master
branch
without
that
revert,
commit
and
the
remove
the
FG
branch
with
the
river
commit.
A
So
yeah,
so
essentially
the
hard
flag
gets
rid
of
my
of
my
working
tree,
so
whatever
files
come
out
of
the
result
of
that
are
not
fitting
a
staging
and
not
fitting
in
my
working
area,
so
I
just
reset
hard
to
one
jump
back
before
head.
So
you
head
tilde
to
do
that.
That's
within
the
master
branch
could
take
a
look
at
our
log
here,
just
to
see
that
we
are
in
fact,
within
the
master
branch
back
to
see.
A
Eb
AEA
81
I
can
check
out
that
remove
PSG
branch
that
I
created
just
a
second
ago
and
take
a
look
at
the
log
there
and
there
we
see
that
it
within
that
branch.
We
do
have
that
revert
of
the
SG,
so
we've
taken
one
commit
that
lived
on
the
master
branch
and
we've
been
able
to
successfully
move
it
to
another
branch.
A
A
A
A
A
The
problem
is
compounded
is
those
credentials
or
that
large
file
large
binary
file
is
then
pushed
up
to
a
remote
if
it
hasn't
been
pushed
up
to
a
remote,
it's
fairly
straightforward
to
recover
from
that
sort
of
situation
right,
you
could
just
do
a
get
reset
and
then
you've
recovered
from
that
sort
of
situation.
But
if
you
have
push
it
up
to
the
remote,
if
you've
committed
some
credentials,
for
example,
well,
there's
other
folks
that
could
have
cloned
down
your
repo
since
you've
committed
your
credentials.
A
So
that's
what
happened
to
me
here
in
this
particular
demonstration
that
I'm
going
to
do
now
and
that
is
that
I
added
a
large
binary
to
this
repo,
not
such
a
large
binary,
I,
really
just
added
my
keynote
presentation
to
the
repo.
It's
only
about
10
Meg's
and
what
we'll
do
is
we
just
used
as
an
example,
we'll
use
git,
filter
branch
to
help
us
remove
that
from
history,
and
just
as
you
saw
as
I've
been
talking
about
a
little
bit
earlier,
you
can
use
git
filter
branch.
A
A
Okay
and
get
LOL
is
just
an
alias
that
I
created
is
for
a
git
log,
and
then
it
has
some
extra
options
in
there
to
give
me
some
branch,
pointers
and
labels
and
to
do
some
ASCII
graph
prettiness
for
me.
So
that's
all
get
lol.
This
is
just
a
another
version
of
get
log.
So
if
I
look
at
my
good
log
here,
I
can
see
that
in
this
particular
case,
I've
got
a
master
branch.
With
my
keynote
presentation
on
it,
I've
got
my
remove
PFD
branch
with
my
revert
that
I
did
a
little
bit
earlier.
A
So
what
we've
got
is
we've
got
a
history
in
which
we
performed
a
recursive.
Merge
original
was
not
a
fast
forward
march,
so
that
commit
f7f.
Zero
in
my
case,
has
two
parents
and
I
did
this
because
I
wanted
to
show
you
we've
looked
at
a
little
bit
of
a
reset
already
I
wanted
to
show
you
a
reset
in
a
scenario
in
which
you've
got
to
reset
past
a
commit
and
merge
commit
that
has
multiple
parents.
A
So
the
first
thing
we
could
do
is
toy
with
that
idea
of
the
reset.
So
in
my
case,
I've
only
added
my
one
commit
fairly
recently,
so
the
commit
that
I
want
to
get
rid
of
through
filter
branch
is
that
commit
in
which
I
added
my
keynote
presentation?
It's
9:03
D,
but
because
I've
merged
now
f7f
zero
could
potentially
be
offensive
as
long
as
well
as
anything
else
that
I
come
at
the
top
of
that
right.
A
So
the
first
thing
we
do
is,
let's
run
a
dis
really
quick
on
those
two
commits
III
47
and
9:03
D,
and
so
the
first
thing
I
wanted
you
to
notice
is
that
this
dis
in
particular
I,
did
with
the
two
dots
right.
So
that's
how
I
disc
those
two
and
you
can
run
the
same
disc
with
those
two
commits
using
three
dots-
and
this
was
mostly
a
fun
thing
to
showcase.
Has
anybody
played
with
this
before
the
two
dot,
syntax
versus
the
three
dot
syntax
and
what
the
differences
are?
A
It's
fun
fun,
dorky,
stuff
right.
So
in
this
particular
case,
when
we
use
the
two
dot
syntax,
what
we're
doing
is
we're
taking
a
disk
the
out
of
the
two
commits
against
one
another
when
we
use
the
three
dot
syntax
we're
taking
a
disk
of
our
last
comment
here,
which
in
this
case
is
9
0,
3
D
against
the
merge
base,
so
9
0,
3,
D
and
E
3
4
2
7
have
a
chimeric
that
in
their
in
their
history,
that's
their
merge
base.
A
So
it
takes
a
disk
against
the
merge
base,
and
so
that's
why
you're
seeing
here
then
when
I
use
the
3
dot
syntax?
What
I'm
seeing
is
that
the
only
thing
that
was
added
is
that
keynote
file,
whereas
when
I'm
using
the
2
dot
syntax
I'd
see
both
the
key
nut
file
and
I
see
my
edition
of
The
BFG,
it's
a
little
easier.
If
we
look
at
the
log
to
explain
to
so
next
time,
I
look
at
the
log
we'll
take
a
look
at
that.
A
So,
armed
with
that
information,
so
by
the
way
here's
that
log
we
were
looking
at
just
a
second
ago,
so
we
were
looking
at
e3,
four
to
seven
and
nine
zero
3d,
and
so
the
two
dots
in
text.
It
was
a
bit
between
those
two,
the
three
dot
syntax
gave
us
the
disk
between
nine,
zero
3d
and
emergencies,
and
you
can
see
from
the
graph
here
that
the
merge
base
is
cted
right
because
that's
that's
where,
where
they
have
common
ancestry,.
A
So
I'm
going
to
reset
past
this
merge
commit
here:
I
need
to
reset
hard
again
and
I'm
going
to
use
this
syntax
here,
head
tilde
to
the
tilde.
So
when
you're
resetting
past
the
merge
commit
that
has
multiple
parents
right
in
that
case
that
f7f
zero
has
two
parent
you
can
specify
which
parent
you'd
like
to
reset
to,
and
so
the
the
the
tilde
two
syntax
will
take
care
of
that
for
us.
A
A
A
A
However,
if
I
had
pushed
this
observer
mode
and
then
other
folks
had
committed
on
top
of
it,
we
would
need
to
go
through
our
history
and
filter
out
any
mention
of
that
keynote
file
or
in
the
case
of
passwords
and
things
like
that
being
committed
to
history
would
have
to
go
through
the
history
and
clear
out
any
mentions
of
those
Korean
Prudential.
So
that's
where
get
filter
branch
comes
in
we'll
take
a
look
at
that
now.
A
A
The
prefilter
rewrites
commit
trees
and
their
contents
so
that
we
can
completely
scrub
out
that
keynote
file,
which
is
what
we
want
to
do
in
this
case
and
then
we'll
run.
The
command
will
specify
the
command
that
we
want
to
run
on
every
commit
in
our
history
here,
which,
in
this
case,
is
just
to
remove
that
particular
keynote
file,
and
then
we've
also
specified
in
here
head,
which
is
where
we'd
like
the
preserved
history
to
be
maintained.
A
A
A
Just
to
verify
we
can
take
a
look
at
that
refs
directory
within
docket
folder,
one
more
time,
just
to
make
sure
that
that's
on
it
it
is
and
be
done
now.
A
couple
of
things
to
note
is:
if
you
push
this
up
to
a
remote
like
github.com,
for
example,
it's
possible
that
remote
is
caching
some
of
these
refs
for
your
projects.
In
fact,
github.com
does
caching
syncs.
A
So
even
if
you
plead
it
out
from
your
local
repo,
in
the
case
you
may
have
to,
you
may
have
to
contact
support
in
order
to
get
that
stuff
that
cache
cleared
from
github
com
github
or
any
other
supports
that
also
can't
control.
How
other
folks
clone
your
project
and
what
they
do
with
your
project
right,
like
everything
else
out
there
on
the
Internet
once
it's
out
there,
it's
been
out
there.
So
if
you
push
something
like
this
up
to
the
remote,
you
can
do
your
due
diligence.
A
You
can
try
to
scrub
it
out
of
the
repo,
but
it's
completely
possible.
Somebody
will
have
grabbed
it
at
some
point
in
time,
and
a
lot
of
folks
also
have
trouble
with
get
filter
branches.
A
lot
of
options
to
filter
branch,
so
you
can
check
out
Roberto
ty,
Lee's
DSG
repo
cleaner,
which
we
talked
about
a
little
bit
earlier.
I
didn't
revert
it
because
I
didn't
like
it.
It
just
reverted
it
as
an
example
of
something
to
revert
and
that's
a
little
bit
easier
to
use
and
could
sometimes
be
faster
as
well.
A
A
Okay,
so
now
that
you've
seen
us
get
deep
into
get
porcelain,
commands,
I
thought
we'd
have
a
little
bit
of
fun
and
we
go
back
to
that
book.
That
I
talked
about
a
little
bit
earlier,
which
is
Alexander
and
a
terrible
horrible,
no
good,
very
bad
day
and
we'll
put
a
little
journey
together
into
a
story.
It's
my
hope
that
that
little
bit
of
a
story
will
help
kind
of
bring
everything
together
for
you.
A
It's
also
my
hope
that,
as
you're
taking
some
of
the
things
that
you're
you're
hearing
at
the
conference
and
you're
teaching
some
of
your
friends
that
a
lot
of
you
were
actually
really
successful
in
teaching
that
you'll
take
some
of
these
tidbits
back
with
you.
So
now,
I
read
your
story,
so
grab
your
blankie,
your
pillow,
your
milk
and
your
cookies
and
follow
along
with
get
and
the
terrible
horrible,
no
good,
very
bad
day
by
the
way
I
don't
have
kids,
so
I
don't
often
get
to
read
stories,
so
this
is
fun
for
me.
A
Besides,
my
friends,
Matt
and
Eric,
who
are
not
here,
always
found
their
bugs
with
git
bisect.
Those
are
the
books
see.
My
most
recent
commit
was
obviously
bad
and
I.
Don't
even
remember
the
last
time.
I
looked
in
my
story,
so
I
figured
only
my
first
commit
with
safe.
It
took
a
couple
of
tries,
but
soon
enough,
I
found
the
commit
that
contained
the
offending
line,
but
when
I
reverted
to
commit
I
got
a
merge
conflict.
A
That's
a
blurry,
merge
conflict
when
that
used.
Git
bisect,
he
reverted
a
missing
semicolon,
a
misspelled
variable
name
and
a
pretty
alarming
lack
of
comments.
It's
a
true
story
about
Matt
when
Eric
use
bisect,
he
reverted
some
missing
environment
variables,
some
badly
indented
blocks
and
part
of
his
grocery
list
that
got
accidentally
pasted
into
his
code.
When
I
used,
bisect
I
just
got
a
gnarly
merge
conflict
after
breakfast
Brianna
who's,
also
not
here
but
she's
from
Chicago
got
to
teach
her
favorite
group
of
students.
A
A
Before
lunch,
I
treated
the
conflict
as
I
would
any
other
conflict
I
opened
the
file
and
removed
the
conflict
markers
then
I
wondered
how
do
I
finish.
This
revert,
get
revert,
didn't
work
did
commit,
didn't
work.
I
wish
I
could
revert
this
day
once
the
revert
was
finished.
I
realized
I
should
have
done
it
in
its
own
branch.
I
wanted
to
get
reset
this
terrible
horrible,
no
good,
very
bad
day.
Nobody
warned
you
about
all
the
cheesy
good
puns
that
day.
That's
what
it
was,
because
that
afternoon
I
actually
tried
get
reset.
A
My
commit
was
made
to
the
wrong
branch,
so
I
figured
I'd,
create
a
new
branch
then
reset
to
the
previous
commit
and
when
I
switched
the
new
branch,
my
rebirth
was
there.
I
then
realized
that
git
cherry-pick
would
have
done
the
same
thing
for
me.
I
wish
I.
Could
cherry
pick
myself
out
of
this
day
later
that
night
I
realized
I
uploaded
my
keynote
presentation
binary
to
the
repo?
What
a
waste
of
space
I
figured
I
could
just
revert
the
commit,
but
that
just
means
that
any
previous
commits
would
still
have
the
file.
A
I
was
happy
with
myself,
but
then
I
realized
a
local
backup
of
what
I
had
cleaned
up
was
still
in
my
kit
directory.
So
I
had
to
clean
that
up
too
I
pushed
my
changes
up
to
github
and
my
push
was
rejected.
It's
because
my
commit
history
was
altered,
so
I
had
to
force
push.
Cinthia
them
told
me
that
github
caches
commits
that
may
still
have
credentials,
may
still
have
my
credentials,
so
I
had
to
contact
support
and
they
removed
the
cache
commits
from
github.
This
was
indeed
a
terrible
horrible,
no
good
very
bad
day.
A
A
So
a
couple
of
quick
shout
out,
so
this
versions
of
this
talk
have
been
given
in
the
past.
So
Alan
Smith
gave
a
talk
like
this
one
at
last
year's
get
merged
with
anybody
here.
For
that
one
it
wasn't
in
the
same
style,
but
it
was
how
to
get
yourself
out
of
sticky
situation
and
then
a
Katy
Siler
Miller
has
a
wonderful
website,
OSHA
Capcom,
which
is
just
how
to
get
yourself
out
of
these
sticky
situations.
A
A
A
A
Right
now
Oh,
so
the
move
commits
to
yes,
absolutely
you'll
get
to
see
every
plate.
A
A
A
You're
right,
that's
probably
more
of
a
result
of
some
late
night.
Writing
commit
messages,
yeah,
absolutely
you're,
absolutely
right!
So
it's
the
as
we
talked
a
little
bit
earlier.
It's
that
check
off
command
that
actually
creates
a
new
branch
based
off
of
the
commitment
master.
So
this
is
get
reset
command.
Does
it
actually
move
the
commit
for
me,
but
that's
the
effect.
So
what
ends
up
happening
is
essentially
to
the
naked
eye.
That's
what
it's
of
happening!
Technically,
it's
not
what
actually
happens
so
you're,
absolutely
right
about
that.