从远程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

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


当前回答

作为Visual Studio Code (vscode, Code)(也可能是其他ide)的参考

我必须执行命令:Git: Fetch (Prune)

命令行替代方案应该是:git fetch——prune

然后重新启动整个IDE。

为了给出一些观点,我将引用BitBucket的码头:

What’s the Difference Between Git Prune,Git Fetch --prune, and Git Remote Prune? git remote prune and git fetch --prune do the same thing: delete the refs to branches that don't exist on the remote. This is highly desirable when working in a team workflow in which remote branches are deleted after merge to main. The second command, git fetch --prune will connect to the remote and fetch the latest remote state before pruning. It is essentially a combination of commands: git fetch --all && git remote prune The generic git prune command is entirely different. As discussed in the overview section, git prune will delete locally detached commits.

其他回答

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

更新:

你可能需要编辑~/.netrc文件:

https://bugs.launchpad.net/ubuntu/+source/git-core/+bug/293553


最初的回答:

为什么禁用ssl?我想这可能与你无法通过https推送有关。我会把它放回去,再试着推一下:

git config –global http.sslVerify true

我遇到这个问题是因为我所在的分支与上游分支具有类似的名称。例如,上游分支被称为示例分支,我的本地分支被称为示例分支/后端。解决方案是更改我的本地分支机构的名称,如下所示:

git branch -m <new name goes here>

这个错误正在发生

git fetch

但在我的情况下,我只是想要更新的主要分支可以使用

git fetch origin main

不是一个解决锁定参考问题的方法,但它帮助我避免了这个问题:P

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

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

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

testBranch /符合 vs。 testbranch / id 2

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

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