It is caused by the difference between the git company username and my own
When submitting code, the global git user configuration is used by default, user name xiaoli
and then pushed to github
After that, I configured the git user of the project and used xiaowang
to push the code again
What should I do if I want to rewrite the user email address of the first git commit?
I use
git rebase -i HEAD~2
But only the last submission information appears.
黄舟2017-05-02 09:43:02
My steps are a bit cumbersome, so I prepared pictures for annotation:
First, open the history record through gitk
, as shown below:
In this example, I am trying to modify the username/email information corresponding to the third submissionmore tests for later change cases
.
The first step is to copy the fourth submissionupdate readme
的SHA1 ID
值,如上图选中部分4535579
(not all necessary, the first eight in my impression are enough)
The second step is to return to the command line and start executing the rebase -i
operation, as follows:
git rebase -i 4535579
At this time, git
will automatically call the configured editor to open an interface, as follows:
The third step is to modify the first row of data (the commit we expect to modify) pick
为edit
as follows:
Save and exit, you can see the following results:
Shuai, now we can easily modify user information through git commit --amend
. The operation is as follows:
git commit --amend --author="LiLei <lilei@qq.com>" --no-edit
Continue to finishrebase
,
git rebase --continue
Open gitk
again and enjoy your results:
Finally, synchronize the result of tampering with the history record to the server through git push --force
Note that forced updates have certain risks. If someone else is submitting code to the server at this time, it will be overwritten by your forced updates.