How to change author email at commit time with hooks

前端 未结 3 1867
萌比男神i
萌比男神i 2020-12-18 09:59

Question says it all.

I want to give my users some privacy by obfuscating their real email addresses in commits by aliases of my own. Is there a hook that can help m

3条回答
  •  再見小時候
    2020-12-18 10:36

    http://progit.org/book/ch6-4.html explains how to rewrite history. Near the bottom, there ist this command

    git filter-branch --commit-filter '
        if [ "$GIT_AUTHOR_EMAIL" = "schacon@localhost" ];
        then
                GIT_AUTHOR_NAME="Scott Chacon";
                GIT_AUTHOR_EMAIL="schacon@example.com";
                git commit-tree "$@";
        else
                git commit-tree "$@";
        fi' HEAD
    

    which changes all commits from schacon@localhost to be from schacon@example.com.

    Caveat: this changes ALL commit-ids from the earliest email-change onward.

提交回复
热议问题