diff options
author | Dejavu Moe <[email protected]> | 2023-05-14 16:05:35 +0800 |
---|---|---|
committer | Dejavu Moe <[email protected]> | 2023-05-14 16:05:35 +0800 |
commit | 81095b1e4716c0ea9c429f680f021ce2783b7bef (patch) | |
tree | 41221c441e4199fc35fd1ebc5cca1bb6ddc88f1e /git/batch-rewrite-git-commit-logs.sh | |
parent | 5dc41d30bacb6b30410afad26c4b65fd2c47b92a (diff) | |
download | gist-81095b1e4716c0ea9c429f680f021ce2783b7bef.tar.gz gist-81095b1e4716c0ea9c429f680f021ce2783b7bef.zip |
rename batch-rewrite-git-commit-logs.sh
Diffstat (limited to 'git/batch-rewrite-git-commit-logs.sh')
-rw-r--r-- | git/batch-rewrite-git-commit-logs.sh | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/git/batch-rewrite-git-commit-logs.sh b/git/batch-rewrite-git-commit-logs.sh new file mode 100644 index 0000000..583bca1 --- /dev/null +++ b/git/batch-rewrite-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 |