Last active
July 12, 2019 06:04
-
-
Save drmingdrmer/7a59b2536e1de5bc6f8696a32a7b58e8 to your computer and use it in GitHub Desktop.
Batch replace word in commit messages with: git history-msg typo type origin/master..mydev_branch
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 | |
usage(){ | |
cat <<-END | |
git history-msg <from> <to> <spec> | |
Replace word <from> to <to> in commit message. | |
Install: | |
copy it into /usr/local/bin/ or somewhere PATH env can find. | |
Usage: | |
To replace "typo" with "type" in all commit messages from origin/master to | |
branch mydev_branch: | |
git history-msg typo type origin/master..mydev_branch | |
END | |
exit 0 | |
} | |
from="$1" | |
to="$2" | |
shift | |
shift | |
script="$(cat <<-END | |
sed 's/$from/$to/g' | |
END | |
)" | |
echo "script: ($script)" | |
git filter-branch -f --msg-filter "$script" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment