From 81095b1e4716c0ea9c429f680f021ce2783b7bef Mon Sep 17 00:00:00 2001 From: Dejavu Moe Date: Sun, 14 May 2023 16:05:35 +0800 Subject: rename batch-rewrite-git-commit-logs.sh --- git/batch-edit-git-commit-logs.sh | 22 ---------------------- git/batch-rewrite-git-commit-logs.sh | 22 ++++++++++++++++++++++ 2 files changed, 22 insertions(+), 22 deletions(-) delete mode 100644 git/batch-edit-git-commit-logs.sh create mode 100644 git/batch-rewrite-git-commit-logs.sh diff --git a/git/batch-edit-git-commit-logs.sh b/git/batch-edit-git-commit-logs.sh deleted file mode 100644 index 583bca1..0000000 --- a/git/batch-edit-git-commit-logs.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash - -# set the committed user information to be replaced -old_user="old userName" -old_email="old@mail.com" -new_user="new userName" -new_email="new@mail.com" - -# 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 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="old@mail.com" +new_user="new userName" +new_email="new@mail.com" + +# 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 -- cgit v1.2.3-54-g00ecf