public
Created

Git aliases to make new commits that fixup or are squashed into previous commits

  • Download Gist
.gitconfig
INI
1 2 3
[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^' -
usage
1 2 3 4 5 6 7 8 9
$ 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^

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.