从远程git存储库克隆后(在bettercodes) 我做了一些改变,承诺 并试图推动:

git push origin master

错误:

错误:不能锁定现有的信息/引用 致命:git-http-push失败

本案例涉及已经存在的存储库。

我之前做的是:

Git配置-global http。sslVerify假 git init Git远程添加[url] git克隆 更改数据 git提交

在'bettercodes'我没有访问git日志。

我用的是Windows。 具体的错误是:

C:\MyWorkStuff\Projects\Ruby\MyProject\>git push origin master
Unable to create branch path https://user:password@git.bettercodes.org/myproject/info/
error: cannot lock existing info/refs
fatal: git-http-push failed

我之前克隆过,然后修改代码并提交。


当前回答

在我的例子中,一个分支被移动到一个子目录,这个目录被称为分支。Git对此感到困惑。当我删除本地分支时(在SourceTree中只需右键单击delete),一切都正常工作。

其他回答

我遇到了一个典型的Mac相关问题,用其他建议的答案无法解决。

Mac的默认文件系统设置是不区分大小写的。

在我的例子中,一个同事显然忘记了为分支创建一个大写字母。

testBranch /符合 vs。 testbranch / id 2

对于Mac文件系统(是的,它可以配置不同)这两个分支是相同的,在这种情况下,你只能得到两个文件夹中的一个。对于剩下的文件夹,您将得到一个错误。

在我的例子中,删除.git/logs/ref/remotes/origin中的有问题的子文件夹解决了问题,因为有问题的分支已经合并回来了。

对我来说,删除。git/info/ref会让事情变得更好。当git没有运行时,不应该有一个引用文件。但在我的情况下,不管出于什么原因,有一个人导致了问题。

删除文件不会删除任何本地提交或分支。

情况1:检查git-server上的分支是否重复。

Example: two branches below are duplicated:

    - upper_with_lower
    - UPPER_with_lower

---> Let consider removing one of them.

情况2:您正在推送的分支与其他分支重复。

这发生在我身上,当我的git远程(bitbucket.org)改变了他们的IP地址。快速解决方法是删除并重新添加遥控器,然后一切都能正常工作。如果你不熟悉如何在git中删除和重新添加一个远程,以下是步骤:

复制现有远程的SSH git URL。你可以使用下面的命令打印到终端: Git remote -v

它会打印出如下内容:

 origin git@server-address.org:account-name/repo-name.git (fetch)
 origin git@server-address.org:account-name/repo-name.git (push)

从本地git repo中删除远程: Git远程rm来源 将遥控器添加回本地回购: Git远程添加源git@server-address.org:account-name/repo-name.git

这个问题现在可能已经解决了。但这是对我有效的方法。

Location: If locked repository is on the server-side: ssh to your git repository on the server. Login as user which has permissions to modify the repository and navigate to the repository on your server. If locked repository is local only: Open the git console and navigate to the repository directory. Run this command: git update-server-info Fix the permissions on your (remote or/and local) repository if you have to. In my case I had to chmod to 777 and chown to apache:apache Try to push again from the local repository: git push