diff options
author | Dejavu Moe <[email protected]> | 2023-05-14 14:27:26 +0800 |
---|---|---|
committer | Dejavu Moe <[email protected]> | 2023-05-14 14:27:26 +0800 |
commit | 5dc41d30bacb6b30410afad26c4b65fd2c47b92a (patch) | |
tree | 12fd79a28e3963c9f2326dcb7aed92a688b0f88c | |
parent | 413b0722ea80ce8c1d2efc80f3909a3f6aaa9b2e (diff) | |
download | gist-5dc41d30bacb6b30410afad26c4b65fd2c47b92a.tar.gz gist-5dc41d30bacb6b30410afad26c4b65fd2c47b92a.zip |
add git/batch-edit-git-commit-logs.sh
-rw-r--r-- | git/batch-edit-git-commit-logs.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/git/batch-edit-git-commit-logs.sh b/git/batch-edit-git-commit-logs.sh new file mode 100644 index 0000000..583bca1 --- /dev/null +++ b/git/batch-edit-git-commit-logs.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +# set the committed user information to be replaced +old_user="old userName" +old_email="[email protected]" +new_user="new userName" +new_email="[email protected]" + +# get global gpg signing key +signingkey=$(git config --global user.signingkey) + +# rewrite the git commit history and sign new commits +git filter-branch --env-filter " + if [ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ] && [ \"\$GIT_AUTHOR_NAME\" = \"$old_user\" ]; then + export GIT_AUTHOR_EMAIL=\"$new_email\" + export GIT_AUTHOR_NAME=\"$new_user\" + export GIT_COMMITTER_EMAIL=\"$new_email\" + export GIT_COMMITTER_NAME=\"$new_user\" + export GIT_COMMITTER_SIGNINGKEY=\"$signingkey\" + export GIT_AUTHOR_SIGNINGKEY=\"$signingkey\" + fi +" --tag-name-filter cat --commit-filter 'git commit-tree -S "$@"' -- --branches --tags
\ No newline at end of file |