Rewrite git history


To fix an email address used for commits:

git filter-branch --commit-filter '
        if [ "$GIT_AUTHOR_EMAIL" = "john@localhost" ];
        then
                GIT_AUTHOR_NAME="John Doe";
                GIT_AUTHOR_EMAIL="[email protected]";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        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: