git modify the username and email address of the author
Preface
The following two points need to be paid attention to:
- Need to be in the top directory (that is
.git
In the directory where the folder is located, right-click to open "Git Bash Here"), otherwise an error will be reported when running the following code; - Make sure that the files in the repository to be modified are the same as the version of the remote repository. If there is any modification that has not been submitted yet, you need to submit or cancel the changes first, otherwise an error will be reported when running the following code.
first step
The following three main changes are:
-
OLD_EMAIL
:Fill in the email address before modification -
CORRECT_NAME
:Fill in the current name -
CORRECT_EMAIL
:Fill in your current email address
Then in "Git Bash Here” Run the code in the open window:
#!/bin/sh git filter-branch --env-filter ' OLD_EMAIL="xxxx@" CORRECT_NAME="chenmeng" CORRECT_EMAIL="xxxx@" 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
Step 2
After executing the first step of the command, execute the following command and force push to the remote repository:
git push --force
Summarize
The above is personal experience. I hope you can give you a reference and I hope you can support me more.