Skip to content

Instantly share code, notes, and snippets.

@peschee
Forked from bkeepers/.gitconfig
Created November 14, 2017 12:39
Show Gist options
  • Save peschee/6e8f490167037cb2a3489052501ae0bb to your computer and use it in GitHub Desktop.
Save peschee/6e8f490167037cb2a3489052501ae0bb to your computer and use it in GitHub Desktop.
Git aliases to make new commits that fixup or are squashed into previous commits
[alias]
fixup = !sh -c 'REV=$(git rev-parse $1) && git commit --fixup $@ && git rebase -i --autosquash $REV^' -
squash = !sh -c 'REV=$(git rev-parse $1) && git commit --squash $@ && git rebase -i --autosquash $REV^' -
$ git commit -am 'bad commit'
$ git commit -am 'good commit'
# Stage changes to correct the bad commit
$ git add .
# Fixup the bad commit. HEAD^ can be replaced by the SHA of the bad commit
$ git fixup HEAD^
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment