Git push 处理报错:remote: error: cannot lock ref 'refs/heads/master': Unable to create '/var/opt/gitlab/git-data-file11/repositories/tomfriwel/test.git/./refs/heads/master.lock': File exists.

报错与处理过程:

$ git push
Counting objects: 21, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (21/21), done.
Writing objects: 100% (21/21), 2.78 KiB | 0 bytes/s, done.
Total 21 (delta 14), reused 0 (delta 0)
remote: error: cannot lock ref 'refs/heads/master': Unable to create '/var/opt/gitlab/git-data-file11/repositories/tomfriwel/test.git/./refs/heads/master.lock': File exists.
remote: 
remote: Another git process seems to be running in this repository, e.g.
remote: an editor opened by 'git commit'. Please make sure all processes
remote: are terminated then try again. If it still fails, a git process
remote: may have crashed in this repository earlier:
remote: remove the file manually to continue.
To gitlab.com:tomfriwel/test.git
 ! [remote rejected] master -> master (failed to update ref)
error: failed to push some refs to 'git@gitlab.com:tomfriwel/test.git'
$ rm -f /var/opt/gitlab/git-data-file11/repositories/tomfriwel/test.git/./refs/heads/master.lock
$ git push

将报错中提示的文件删除,再push就行了。

参考:
fatal: unable to create 'refs/heads/master.lock': File exists fatal: - Getting this error while pushing the commits

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容