git push --all 的 Git 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4001847/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:40:00  来源:igfitidea点击:

Git problems with git push --all

gitpush

提问by Chris Turner

I have a base repository that lives on a UNC \machine\share ....etc. I have a local clone that I work on in the master branch and occasionally merge over to the "stable" branch.

我有一个位于 UNC \machine\share ....etc 上的基本存储库。我有一个在 master 分支上工作的本地克隆,偶尔会合并到“稳定”分支。

usually I do a git push --all

通常我做一个 git push --all

to move all changes in all branches up to the server. After creating a new branch git branch MultiCompany

将所有分支中的所有更改移至服务器。创建新分支后 git branch MultiCompany

and then pushing it to the server git push --all

然后推送到服务器 git push --all

which creates the branch on the server also. I did some work, committed all the changes in multicompany branch and then tried to do a git push --all

这也在服务器上创建了分支。我做了一些工作,提交了 multicompany 分支中的所有更改,然后尝试做一个 git push --all

and got the following error:

并得到以下错误:

cdturner@OAHU ~/desktop/git sourcetree/maerekai.web.framework (multicompany) 
$ git push --all
Counting objects: 28, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (22/22), done.
Writing objects: 100% (23/23), 11.34 KiB, done.
Total 23 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (23/23), done.
error: Ref refs/heads/multicompany is at bd5a32df35ce8d5ae30ce999af34c4c5f35581df but expected 0000000000000000000000000000000000000000
remote: error: failed to lock refs/heads/multicompany
To //pluto/users/cdturner/Git repositories/Maerekai.web.framework.git
 ! [remote rejected] multicompany -> multicompany (failed to lock)
error: failed to push some refs to '//pluto/users/cdturner/Git repositories/Maerekai.web.framework.git'

I tried to back out the last commit withgit reset --hard HEAD^

我试图退出最后一次提交git reset --hard HEAD^

and then retried the push.....

然后重试推送.....

cdturner@OAHU ~/desktop/git sourcetree/maerekai.web.framework (multicompany)
$ git push --all
Total 0 (delta 0), reused 0 (delta 0)
error: Ref refs/heads/multicompany is at bd5a32df35ce8d5ae30ce999af34c4c5f35581df but expected 0000000000000000000000000000000000000000
remote: error: failed to lock refs/heads/multicompany
To //pluto/users/cdturner/Git repositories/Maerekai.web.framework.git
 ! [remote rejected] multicompany -> multicompany (failed to lock)
error: failed to push some refs to '//pluto/users/cdturner/Git repositories/Maerekai.web.framework.git'`

回答by A.L.

For the record, I believe the root cause of this problem was the difference in capitalisation between the local and remote branch names, and the case-insensitive nature of the Windows share that hosted the remote repository.

作为记录,我认为这个问题的根本原因是本地和远程分支名称之间的大小写不同,以及托管远程存储库的 Windows 共享不区分大小写的性质。

We just encountered this exact same error and were able to resolve the problem simply by renaming the local branch to match the capitalisation of the existing remote branch.

我们刚刚遇到了这个完全相同的错误,并且能够通过重命名本地分支以匹配现有远程分支的大小写来解决问题。

See here how to rename a local branch.

请参阅此处如何重命名本地分支

In Windows, due to capitalization, you may need to take two steps:

在 Windows 中,由于大小写,您可能需要执行两个步骤:

git branch -m example foo
git branch -m foo EXAMPLE

回答by Adam Dymitruk

do a git fsck --full on the remote repo. The remote repo may have become corrupt. Clone another one from the remote. Replace the original remote with this one. You should now be able to push again. Something has happened to the remote repo. Nothing you're doing is out of line with regular use.

在远程仓库上执行 git fsck --full 。远程存储库可能已损坏。从遥控器克隆另一个。用这个替换原来的遥控器。您现在应该能够再次推动。远程仓库发生了一些事情。您所做的一切都与常规使用不符。

回答by hjc1710

An error I found was trying to push a branch developto a repository that had branches named: develop/1148and develop/693. git isn't ok with this (I forget why), so deleting those branches (if possible) fixed this hangup.

我发现的一个错误是试图将一个分支推develop送到一个名为:develop/1148develop/693. git 对此不满意(我忘记了原因),因此删除这些分支(如果可能)解决了这个问题。

回答by Chris Turner

Thanks, git fsck --full reported "dangling commit"

谢谢, git fsck --full 报告了“悬空提交”

so git prune blew away the offending stuff and I got to type it in again. Btu at least the trees are all resolved..

所以 git prune 吹走了有问题的东西,我必须再次输入。Btu 至少树都解决了..

Thanks for the help.

谢谢您的帮助。