简体   繁体   English

当推送到Github时,Xcode错误消息“远程存储库拒绝提交”

[英]Xcode error message “The remote repository rejected commits” when pushing to Github

I have a branch named develop that I pulled on, added some code, committed, pulled again, and am now trying to push but I get the following error message in Xcode: 我有一个名为develop的分支,我继续,添加了一些代码,提交,再次拉,现在我试图推送但是我在Xcode中收到以下错误消息:

The remote repository rejected commits. 远程存储库拒绝提交。
Make sure you have permission to push to the remote repository and try again. 确保您有权推送到远程存储库并再试一次。

I switched to a different branch named feature and was able to pull and push on it fine. 我切换到一个不同的分支命名功能 ,并能够拉动和推动它很好。

I went to Xcode > Preferences > Accounts > Repositories then clicked on the repository I'm working on and verified my credentials and even re-entered them. 我去了Xcode> Preferences> Accounts> Repositories然后点击了我正在处理的存储库并验证了我的凭据甚至重新输入了它们。 But I still have the same problem (the feature branch works but the develop one throws up that message). 但我仍然有同样的问题(功能分支工作,但开发人员抛出该消息)。

Why does the push work on one branch but not the other? 为什么推送工作在一个分支而不是另一个分支?

I got this error today and it wasn't until I tried to commit via another method did I actually find the reason. 我今天得到了这个错误,直到我尝试通过另一种方法提交我才真正找到原因。 I had a file that was 230Mb and GitHub doesn't allow files that big (or at least for the account I have). 我有一个230Mb的文件,GitHub不允许大文件(或至少我的帐户)。 So Xcode just wasn't being very helpful with its error message 所以Xcode对它的错误信息不是很有帮助

GitHub repositories can be configured with branch protection . GitHub存储库可以配置分支保护 You probably have permission only to push/pull the feature branch and only to pull (but not push) the develop branch. 您可能只有推/拉feature分支的权限,只能拉(但不推) develop分支。

This happened to me because I branched off of our main branch and named my branch incorrectly, so I branched off that misspelled branch to fix the name and then deleted it which killed the upstream branch for Git. 这发生在我身上,因为我分支了我们的主分支并且错误地命名了我的分支,所以我分支了拼错的分支来修复名称,然后删除了它杀死了Git的上游分支。

The solution was to set the upstream via command line: 解决方案是设置上游通过命令行:

git push --set-upstream origin theUpstreamBranchYouWantToSet

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM