every blog every motto: You can do more than you think.
https://blog.csdn.net/weixin_39190382?type=blog
0. Preface
Modify git author and committer information
1. Text
1.1 Prerequisites
1.1.1 Authors and Submitters
The author is the information we see in git log, as follows:
For the modification method, refer to: Article -> Modify User Information
The author and submitter are generally the same by default, that is, our locally configured git account.
However, if the author is modified, the submitter information will not change accordingly, as shown in the following figure (both have been modified):
1.2 Modify the submitter
1.2.1 Method 1
Description: This method is generally between our submissions
A. View
$ git config user.name
$ git config user.email
B. Modify
global
# 设置全局
git config --global user.name "Author Name"
git config --global user.email "Author Email"
current project repository
# 或者设置本地项目库配置
git config user.name "Author Name"
git config user.email "Author Email"
1.2.1 Method 2
Modify History Committers
- OLD_EMAIL is the historical mailbox, no name is required, use the mailbox to search for content
- CORRECT_NAME, CORRECT_EMAIL is the submitter and submission email address after modification
git filter-branch --env-filter '
OLD_EMAIL="old [email protected]"
CORRECT_NAME="new name"
CORRECT_EMAIL="new [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
According to the filled old email, all the information related to the old email has changed, as follows:
reference
[1] https://blog.csdn.net/weixin_39190382/article/details/128778119
[2] https://blog.csdn.net/zjy_love_java/article/details/113284685#:~:text=git%20%E5%91%BD%E4%BB%A4%E4%BF%AE%E6%94%B9%E4%BB%A3%E7%A0%81%E6%8F%90%E4%BA%A4%E4%BA%BA%201%201.%20git%20log%20%E6%9F%A5%E7%9C%8B%E6%8F%90%E4%BA%A4%E8%AE%B0%E5%BD%95%202,2.%20%E8%AE%BE%E7%BD%AE%E5%85%A8%E5%B1%80%E6%8F%90%E4%BA%A4%E4%BA%BA%E5%92%8C%E6%8F%90%E4%BA%A4%E9%82%AE%E7%AE%B1%203%203.%20%E8%AE%BE%E7%BD%AE%E9%A1%B9%E7%9B%AE%E6%8F%90%E4%BA%A4%E4%BA%BA%E5%92%8C%E6%8F%90%E4%BA%A4%E9%82%AE%E7%AE%B1%204%204.%20%E4%BF%AE%E6%94%B9%E5%8E%86%E5%8F%B2%E8%AE%B0%E5%BD%95%E6%8F%90%E4%BA%A4%E4%BA%BA