I'm attempting to re-write some git history using the script below, slightly modified from this blog, which updates emails. I initially wanted to be more secure and decided to enable Block command line pushes that expose my email
on GitHub, but realized my contribution graph was no longer updating.
#!/bin/bash
# Taken from https://blog.tinned-software.net/rewrite-author-of-entire-git-repository/
if [[ $# -eq 3 ]]; then
git filter-branch -f --env-filter "
if [ '$GIT_COMMITTER_EMAIL' = '$1' ]; then
export GIT_COMMITTER_NAME='$2'
export GIT_COMMITTER_EMAIL='$3'
fi
if [ '$GIT_AUTHOR_EMAIL' = '$1' ]; then
export GIT_AUTHOR_NAME='$2'
export GIT_AUTHOR_EMAIL='$3'
fi
" --tag-name-filter cat -- --all
else
echo "usage: $0 OLD_EMAIL NEW_EMAIL NEW_NAME"
echo ""
echo " OLD_EMAIL The email address to be replaced in the commits"
echo " NEW_EMAIL The new author email address to be used in the commit matching OLD_EMAIL"
echo " NEW_NAME The name which should be used in the commit matching OLD_EMAIL"
fi
The script runs and I get no errors form bash, but git tells me that none of the refs have been modified.
WARNING: Ref 'refs/heads/branch1' is unchanged
WARNING: Ref 'refs/heads/master' is unchanged
WARNING: Ref 'refs/remotes/origin/master' is unchanged
WARNING: Ref 'refs/remotes/origin/branch1' is unchanged
WARNING: Ref 'refs/remotes/origin/master' is unchanged
Why it lists origin/master
more than once is beyond me, but this is otherwise all of the branches for this repo, meaning nothing got updated. I did run git shortlog -sne --all
before and after to make sure. I've been unable to find any documentation on this error as it directly relates to git. Is there something missing in the script?