DEV Community

Janardhan Pulivarthi
Janardhan Pulivarthi

Posted on

How to rewrite history in git repo

Changing the email address and author

ref: https://git-scm.com/book/en/v2/Git-Tools-Rewriting-History

/d/repo/go-training (main)
$ git filter-branch --commit-filter '
        if [ "$GIT_AUTHOR_EMAIL" = "person@example.com" ];
        then
                GIT_AUTHOR_NAME="New Person";
                GIT_AUTHOR_EMAIL="new.person@example.com";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD

Proceeding with filter-branch...

Rewrite 8430e1b897d5419fdasfsafasfsa685db2ae2327 (1/3) (0 seconds passed, remainRewrite 77c97ee4fsdafasfasdfaf5f9276348435fb768487e (2/3) (1 seconds passed, remainRewrite 6bb1508502ff0add7ae46d121a8d33a565f1889c (2/3) (1 seconds passed, remaining 0 predicted)
Ref 'refs/heads/main' was rewritten
Enter fullscreen mode Exit fullscreen mode

Top comments (0)