by brlewis · 7y ago · 0 comments
git filter-branch --env-filter '
old_email=megatron@example.com
new_email=redacted
if [ "$GIT_COMMITTER_EMAIL" = "$old_email" ] ; then
export GIT_COMMITTER_EMAIL="$new_email"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$old_email" ] ; then
export GIT_AUTHOR_EMAIL="$new_email"
fi
' -- --all
This is “safe” in the sense that you can go back to the old version with the reflog if you screw things up.git filter-branch is perfect for this kind of wholesale revision. filter-branch is essential for tasks like: open-sourcing repos that need some kind of cleanup, massaging repos generated by a VCS migration tool, etc. For example, years ago I participated in the move of a large CVS repo to git; there was significant filter-branch post-processing required to create an acceptable baseline)
git filter-branch --env-filter " \
export GIT_AUTHOR_NAME=Dade\ Murphy \
GIT_AUTHOR_EMAIL=zer0cool@example.com \
GIT_COMMITTER_NAME=Dade\ Murphy \
GIT_COMMITTER_EMAIL=zer0cool@example.com"https://stackoverflow.com/questions/750172/how-to-change-the...