I was writing a simple script in the school computer, and committing the changes to Git (in a repo that was in my pendrive, cloned from my computer at home). After several c
This is a more elaborated version of @Brian's version:
To change the author and committer, you can do this (with linebreaks in the string which is possible in bash):
git filter-branch --env-filter '
if [ "$GIT_COMMITTER_NAME" = "" ];
then
GIT_COMMITTER_NAME="";
GIT_COMMITTER_EMAIL="";
GIT_AUTHOR_NAME="";
GIT_AUTHOR_EMAIL="";
fi' -- --all
You might get one of these errors:
If you want to force the run in spite of these errors, add the --force
flag:
git filter-branch --force --env-filter '
if [ "$GIT_COMMITTER_NAME" = "" ];
then
GIT_COMMITTER_NAME="";
GIT_COMMITTER_EMAIL="";
GIT_AUTHOR_NAME="";
GIT_AUTHOR_EMAIL="";
fi' -- --all
A little explanation of the -- --all
option might be needed: It makes the filter-branch work on all revisions on all refs (which includes all branches). This means, for example, that tags are also rewritten and is visible on the rewritten branches.
A common "mistake" is to use HEAD
instead, which means filtering all revisions on just the current branch. And then no tags (or other refs) would exist in the rewritten branch.