blob: 583bca18d1caddbcfb6b240168f740ebb925c1c5 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
|