Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

批量修改git commit author #16

Open
varHarrie opened this issue Apr 25, 2017 · 0 comments
Open

批量修改git commit author #16

varHarrie opened this issue Apr 25, 2017 · 0 comments
Labels
Milestone

Comments

@varHarrie
Copy link
Owner

有这么一个需求,我们在新建项目的时候,忘了修改nameemail,沿用了global中的设置,如果提交了一次commit,可以使用:

git commit –amend –author=‘[email protected]

修改上一次提交的author信息

但是,如果提交过不止一次,就不能使用这个方法了。下面是一个批量修改的办法:

#!/bin/sh

git filter-branch --env-filter '
OLD_EMAIL="[email protected]"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="[email protected]"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_COMMITTER_NAME="$CORRECT_NAME"
    export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
    export GIT_AUTHOR_NAME="$CORRECT_NAME"
    export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags

此方法出自github help

这里有关于这个问题的更多讨论

@varHarrie varHarrie added this to the Snippets milestone Aug 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant