Rewrite git history


To fix an email address used for commits:

git filter-branch --commit-filter '
        if [ "$GIT_AUTHOR_EMAIL" = "[email protected]" ];
        then
                GIT_AUTHOR_NAME="John Doe";
                GIT_AUTHOR_EMAIL="[email protected]";
                git commit-tree "[email protected]";
        else
                git commit-tree "[email protected]";
        fi' HEAD

source

To remove all history:

git reset $(git commit-tree HEAD^{tree} -m 'Initial commit')

source

More tools:

Date: 2020-08-07

Tags:  git

Share: