Created
February 19, 2013 14:12
-
-
Save bkeepers/4986257 to your computer and use it in GitHub Desktop.
Git aliases to make new commits that fixup or are squashed into previous commits
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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^' - |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ 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
Another useful addition is --autostash (to rebase), so the command will not be interrupted when you got unstaged changes