Git-致命:无法创建“ /path/my_project/.git/index.lock”:文件存在

当尝试将项目移至Git仓库时,遇到'无法创建.index.lock'的错误。尝试了更改权限、初始化Git、创建新仓库,但问题依然存在。解决方案包括退出可能占用的Xcode,等待文件系统同步,或者直接结束Git进程。
摘要由CSDN通过智能技术生成

本文翻译自:Git - fatal: Unable to create '/path/my_project/.git/index.lock': File exists

I am still getting this error message, when I try to move my project tree on to git repo. 当我尝试将项目树移至git repo时,我仍然收到此错误消息。

I checked the permissions of my directory with this project and these are set on 777. In terminal in the directory with my_project I set: 我检查了此项目的目录权限,这些权限设置在777上。在带有my_project目录的终端中,我设置了:

git init git初始化

and then if I try 然后,如果我尝试

git add . git添加

or 要么

git commit -m "first upload" git commit -m“首次上传”

so I'll get the error 所以我会得到错误

fatal: Unable to create '/path/my_proj/.git/index.lock': File exists.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

I tried also create a new repo and there to commit it, but unfortunately still the same error message. 我试过也创建一个新的仓库,并提交它,但是不幸的是仍然是同样的错误信息。

What is the cause of problem? 问题原因是什么?


#1楼

参考:https://stackoom.com/question/WywJ/Git-致命-无法创建-path-my-project-git-index-lock-文件存在


#2楼

尝试退出Xcode-由于它是git客户端,因此您必须退出Xcode以避免命令行上的git问题。


#3楼

解决此问题的方法是将三个xcode / project文件复制到目录中,然后创建新目录(在其他位置),然后粘贴三个文件/目录。


#4楼

In Windows, do this in the command prompt from the repo directory: 在Windows中,从repo目录的命令提示符中执行以下操作:

cd .git
del index.lock

UPDATE: I have found that I don't need to do this procedure if I wait a moment after I close out the files I'm working on before I try to switch branches. 更新:我发现,如果我关闭正在处理的文件之后稍等片刻,然后再尝试切换分支,则无需执行此过程。 I think sometimes this issue occurs due to git catching up with a slow file system. 我认为有时由于git赶上缓慢的文件系统而出现此问题。 Other, more git-knowledgeable developers can chime in if they think this is correct. 如果他们认为这是正确的,则其他更具git知识的开发人员也可以加入。


#5楼

Also we can just kill git process. 我们也可以杀死git进程。 I receive the same issue via GUI app for git, something goes wrong and git makes some work infinitely. 我通过GUI应用程序收到git的相同问题,出现问题,并且git无限工作。 Killing process will freeze application that works with git, just restart it and everything will be ok. 杀死进程将冻结与git一起使用的应用程序,只需重新启动它,一切都会好的。


#6楼

如果您使用的是#intelliJ IDE之一并且收到此消息(我使用的是#webtorm ),请注意,由于隐藏了项目文件夹之一(内部设置),因此可能会发生此问题,并且这可能会阻止GIT合并。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值