Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.

Fixup and autosquash

2.
- I like to start git repositories with an
empty commit, as it creates a rebase
point at the beginning of the repository
- because yes, you can make a mistake
in the initial commit
- creating a develop branch to follow
process
- and now a feature branch
A LITTLE ENVIRONMENT SETUP
git init .
git commit -m "Initial commit" --allow-empty
git checkout -b develop
git checkout -b getting_started
Fixup and Autosquash // Shawn Sorichetti

7.
- when I created the initial code
I made a mistake, did you catch
it?
- failed to identify name as a
variable so name is printed
rather than the $name contents
INITIAL MISTAKE
#!/usr/bin/env perl
use strict;
use warnings;
print "Enter your name: ";
my $name = <STDIN>;
chomp($name);
print "nHi namen";
Fixup and Autosquash // Shawn Sorichetti

10.
- As this was a mistake and
doesn't change the story, it
should not be a separate commit
- just fix the existing commit
- the change has been staged
- but how do we deal with this
mistake
THEN WHAT DO YOU DO?
Fixup and Autosquash // Shawn Sorichetti

11.
- create a new commit with a
distinctive subject reminding
me of what I need to do
- yeah... I forgot.
WHAT I USED TO DO
git commit -m "XXX Rebase and fix up into Initial commit"
Fixup and Autosquash // Shawn Sorichetti

15.
- creates a special kind of commit
that includes the subject of the
commit to be fixed
- now this isn't really what I
normally do, I use git log to
find the commit and capture the
SHA and just use that
WHAT I SHOULD HAVE DONE
git commit --fixup :/Initial
Fixup and Autosquash // Shawn Sorichetti

16.
- which is a regex
- this for instance results in the latest commit with the
message matching Initial
- This power by the way is brought to you by rev-parse
- the --fixup argument accepts anything that git rev-
parse will allow
- highly recommend having a read through there
- it's amazing what all can be done to specify a
commit
- one of which is the latest commit of the file, but
that's another talk...
WHAT I SHOULD HAVE DONE
git commit --fixup :/Initial
git help rev-parse
Fixup and Autosquash // Shawn Sorichetti

26.
- this was the merge request
state before the change was
push
THE MERGE REQUEST
Fixup and Autosquash // Shawn Sorichetti

27.
- GitLab has automatically
marked the merge request as
Work in Progress
- it will not allow this merge
request to be completed until
this state is resolved.
THE MERGE REQUEST NOW
Fixup and Autosquash // Shawn Sorichetti

28.
- GitLab has added the fact
that this code has changed
directly to the discussion
- this allows the original
reviewer to mark the
discussion as resolved
AND WHAT DOES THE FEEDBACK LOOK LIKE?
Fixup and Autosquash // Shawn Sorichetti

29.
- once the approval is obtained, we
rebase the branch again, to squash the
fixup
- and we force push the branch to get
the clean history
- at this point the Merge Request Work
in Progress status needs to be
resolved
APPROVED
git rebase -i develop --autosquash
git push --force-with-lease origin getting_started
Fixup and Autosquash // Shawn Sorichetti