Last active
May 18, 2022 13:14
-
-
Save esebastian/db27fbbef193c75679e5 to your computer and use it in GitHub Desktop.
Amend the commit message of one specific git commit and rebase to apply the changes
This file contains hidden or 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
#!/bin/sh | |
# Amend the commit message one specific commit and rebase | |
# to apply the changes. Given the SHA hash or a reference | |
# of the commit to amend, it checkouts the commit, amends | |
# it interactively and rebases the repo history in master. | |
# | |
# This action is destructive to your repo's history and this | |
# should not be performed on a repo that has been shared with | |
# others, because it will force them to reset their history. | |
# | |
# Use at your own risk. | |
# | |
# Put the script in your path and invoke it this way: | |
# git amend <SHA> | |
if [[ ! -n $1 ]]; then | |
echo "usage: git amend <SHA>\n" | |
exit 1 | |
fi | |
echo "Amending $1..." | |
git checkout $1 && git commit --amend && git rebase HEAD master | |
[[ $? -eq 0 ]] && echo Done! | |
[[ $? -ne 0 ]] && echo Error! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment