Created
June 26, 2012 06:14
-
-
Save dpwright/2993701 to your computer and use it in GitHub Desktop.
Git alias to amend a specific commit earlier in the tree
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
amend-commit = "!f() { START=`(git symbolic-ref -q HEAD || git rev-parse HEAD) | cut -d"/" -f 3`; git checkout -q $1 && git commit --amend && git rebase --onto HEAD $1 $START; }; f" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Written following a brief discussion in #git on freenode (based on a suggestion by constant and suggested implementation by frogonwheels). This alias makes amending earlier commit messages easier, but is a bit dangerous as if there are branches based on the earlier commit other than that which is currently checked out, they will need to be rebased manually onto the new, amended commit.
Works even if you're in a detached HEAD state, but as above, any branches will need to be manually rebased.