git修改提交的用户名

场景分析

试想一下这样的场景,你先在自己的电脑上上创建了一个项目,并且把他添加到了git仓库,然后提交到了Github。但是,下一次,你在公司的电脑上clone了这个项目,并且修改了文件,当你提交到Giuhub的时候,你会发现,提交的用户名是当前系统的,和你之前的不一样。

解决方案

那么,我们现在想要把这个提交信息里面的用户名和密码改成我们自己的,有什么办法吗?

答案是有的。Github官方提供了一个方法,不过这个会影响提交历史。如果是你一个人的项目,可以这么做,如果是多人合作的项目,不建议这么做。

具体办法:Changing author info

也可以这么做

Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

git config --global user.name "Your Name"
git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author
原文地址:https://www.cnblogs.com/tangyouwei/p/5135525.html