预期提交者名称 Git 推送问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/33008916/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Expected Committer Name Git Push Issue
提问by NoNaMe
I'm trying to commit/Push some code to GIT, but when I tried to commit the code using SourceTree it gave me an error:
我正在尝试向 GIT 提交/推送一些代码,但是当我尝试使用 SourceTree 提交代码时,它给了我一个错误:
remote: Push rejected.[K
remote:
remote: refs/heads/Branch Details: 6a5d6d4cdd53db591e53db78c51225a619af487f: expected committer name 'Your Name Complete' but found 'Your Name'[K
remote:
Commit is done, but code is not pushed to remote.
提交已完成,但代码未推送到远程。
I just noticed in the Global setting that my was "Your Name" and I changed it (TO: Your Name Complete) in Global configuration, also verified the name in Tools --> Options
and its showing "Your Name Complete" now.
I also tried:
我刚刚在全局设置中注意到我是“你的名字”,我在全局配置中更改了它(TO:你的名字完整),现在还验证了名字Tools --> Options
并显示“你的名字完整”。我也试过:
git config --global user.name "Correct User Name"
git config --global user.email "[email protected]"
but still unable to Push the changes, still the same error can any one help me to push the code to remote repository?
但仍然无法推送更改,仍然出现相同的错误,有人可以帮助我将代码推送到远程存储库吗?
回答by VonC
Following the example of this blog post(it was for a tag, in your case it is for a branch HEAD), you would need to amend at least just the branch HEAD you want to push:
按照此博客文章的示例(它用于标记,在您的情况下用于分支 HEAD),您至少需要修改要推送的分支 HEAD:
git commit --amend --allow-empty --author="LastName, FirstName <[email protected]>"
And then push.
然后推。
回答by NoNaMe
Hopefully, if user may reset/revert the local commit and then recommit the code after correcting the name in global configuration, this will make the push successful. Here is a way to revert commit:
希望如果用户可以重置/恢复本地提交,然后在更正全局配置中的名称后重新提交代码,这将使推送成功。这是一种恢复提交的方法:
git reset HEAD~1 -- revert changes made to the index (i.e., that you have added)
For now, I tried the empty commit and also tried to commit the same file with some space (to attempt a fake commit) but both (above solution and fake commit) did not work for me. Then I just removed the cloned repository and re cloned it and then committed the code again and this time Push was done successfully, as I already changed the name in configurations.
现在,我尝试了空提交,并尝试用一些空间提交同一个文件(尝试假提交),但两者(以上解决方案和假提交)对我都不起作用。然后我只是删除了克隆的存储库并重新克隆它,然后再次提交代码,这次推送成功完成,因为我已经在配置中更改了名称。
回答by Kaashan
Posting this answer as I faced a similar issue today and the suggestions provided in other answers for this topic didn't worked for me. Here is what I did to resolve the issue:
发布此答案是因为我今天遇到了类似的问题,并且针对该主题的其他答案中提供的建议对我不起作用。这是我为解决问题所做的工作:
a) Verified that user.name and user.email were as expected for local and global git file
a) 验证 user.name 和 user.email 是否符合本地和全局 git 文件的预期
Local Git config file -> name 'config', No extension, stored under'.git' directory of local repo folder
本地 Git 配置文件 -> 名称 'config',无扩展名,存储在本地 repo 文件夹的 '.git' 目录下
Global Git config file -> No name, just extension , named '.gitconfig', stored inside user's profile folder like "C:\Users\yourusername" folder
全局 Git 配置文件 -> 没有名称,只有扩展名,名为“.gitconfig”,存储在用户的配置文件文件夹中,如“C:\Users\yourusername”文件夹
This was fine.
这很好。
b) My previous commit was pushed successfully. So, I compared the previous git push and the new git push. I observed that with the new git push I was trying to push more than one commits and though of combining it to single commit. After the commits were combined, I was able to push my changes successfully.
b) 我之前的提交被成功推送。所以,我比较了之前的 git push 和新的 git push。我观察到,使用新的 git push 我试图推送多个提交,尽管将其合并为单个提交。合并提交后,我能够成功推送我的更改。