Created
June 17, 2009 03:54
-
-
Save zwily/131069 to your computer and use it in GitHub Desktop.
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] | |
amend-message = "!bash -c ' \ | |
c=$0; \ | |
if [ $c == \"bash\" ]; then echo \"Usage: git amend-message <commit>\"; exit 1; fi; \ | |
saved_head=$(git rev-parse HEAD); \ | |
commit=$(git rev-parse $c); \ | |
commits=$(git log --reverse --pretty=format:%H $commit..HEAD); \ | |
echo \"Rewinding to $commit...\"; \ | |
git reset --hard $commit; \ | |
git commit --amend; \ | |
for X in $commits; do \ | |
echo \"Applying $X...\"; \ | |
git cherry-pick $X >> /dev/null; \ | |
if [ $? -ne 0 ]; then \ | |
echo \" apply failed (is this a merge?), rolling back all changes\"; \ | |
git reset --hard $saved_head; \ | |
echo \" ** AMEND-MESSAGE FAILED, sorry\"; \ | |
exit 1; \ | |
fi; \ | |
done; \ | |
echo \"Done\"'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment