从远程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 gc --prune=now

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

其他回答

运行命令git update-ref -d refs/heads/origin/branch修复。

在我的例子中,它与我已经创建的分支名称相连接。

为了解决这个问题,我创建了一个分支,它的名字肯定不应该存在,比如:

git checkout -b some_unknown_branch

然后我清除了所有其他分支(不活动),因为它们只是不必要的垃圾。

git branch | grep -v \* | grep -v master | xargs git branch -D

然后用我想要的名字重命名我的当前分支,比如:

git checkout -m my_desired_branch_name

这就是我的工作方式。

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

还有更快的选择:

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

我通过以下方法解决了这个问题

git branch --unset-upstream
rm .git/refs/remotes/origin/{branch}
git gc --prune=now
git branch --set-upstream-to=origin/{branch} {branch}
#or git push --set-upstream origin {branch}
git pull

这假设你的本地和远程分支是对齐的,你只是得到的refs错误为非致命的。

对我有用的是:

删除. /日志/文献/遥控器/产地/分支 删除. / refs /遥控器/产地/分支 运行git gc——prune=now

更多关于git gc命令的信息请访问:https://git-scm.com/docs/git-gc