从远程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 remote prune origin

来源:https://codedaily.in/git-error-cannot-lock-refs/

其他回答

你想尝试做:

git gc --prune=now

参见https://www.kernel.org/pub/software/scm/git/docs/git-gc.html

这就是我的工作方式。

在服务器上查找Apache DAV锁文件(例如/var/lock/apache2/DAVlock) 删除它 重新创建具有写权限的web服务器 重新启动web服务器

还有更快的选择:

在服务器上查找Apache DAV锁文件(例如/var/lock/apache2/DAVlock) 清空文件:cat /dev/null > /var/lock/apache2/DAVlock 重新启动web服务器

在我的情况下,在收到这条消息后,我执行了checkout命令,并得到了以下消息:

Your branch is based on 'origin/myBranch', but the upstream is gone.
  (use "git branch --unset-upstream" to fixup)

执行这个命令后,我恢复了正常。

除了对这个问题已经提供的许多答案之外,简单地检查一下您的机器中存在的本地回购分支和远程中不存在的本地回购分支,将会有所帮助。在这种情况下,你不用

去修剪

正如许多人所建议的那样。

只需删除本地分支

git branch -d <branch name without a remote tracking branch by the same name>

如所附截图所示,当您确定本地分支没有跟踪远程分支时,使用-D强制删除。

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

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