在用webstrom进行git提交时报错Unable to create 'E:/vue_project/.git/index.lock': File exists.如何来进行处理。

 

今天用webstrom git上传代码,结果爆了个错。(以下是报错信息)

 

 

 

 

 在报错后,百度一下,很多人会让我们删除.git中的index.lock文件

但是!

删除之后,再回到webstrom,项目文件全变红了。

也可强行提交,不过的git会出现抽风的问题,会删除掉我的配置文件。

我认为原因如下:

  我在.gitgnore中设置了git不可操作文件,但是目前所有爆红的文件对于git来说就是已经删除的文件。如果强行提交,git会识别这些爆红的文件,将其状态改为不是已删除的文件。而经过.gitgnore文件的过滤,自动跳过了我的配置文件,其他文件都恢复了,唯有这里面记录的文件依旧是已删除状态,这样的话提交上去的时候就会自动删除掉git上的被记录文件。(目前经过测试)(该原因全凭本人理解,说的不对还请大佬留言改正。)

 

还需要输入命令来修复一下才好。

 

我的建议是出现这样的问题,查看一下有没有打开的vscode啥的开发工具,建议关掉。

 

重启webstrom,如果重启还没用的话,那么直接重启电脑,如果重启电脑还不管用,那么就一个一个的上传文件。

 

后缀相同的文件一起commit push,上传提交。

比如 .vue的一起提交,.js的文件一起提交上传,可临时解决这个办法

 

 

 

 

 

最后发一下错误信息方便各位快速定位

              提交失败,错误
			0 file committed, 4 files failed to commit: 提交
			> running pre-commit hook: lint-staged
			[?25lRunning tasks for *.js [started]
			Running tasks for *.vue [started]
			vue-cli-service lint [started]
			vue-cli-service lint [started]
			vue-cli-service lint [completed]
			git add [started]
			vue-cli-service lint [completed]
			git add [started]
			git add [completed]
			Running tasks for *.js [completed]
			git add [failed]
			→ × git add found some errors. Please fix them and try committing again.
			
			Unable to create 'E:/1LangChaoOffice/vue_project/.git/index.lock': File exists.
			
			Another git process seems to be running in this repository, e.g.
			an editor opened by 'git commit'. Please make sure all processes
			are terminated then try again. If it still fails, a git process
			may have crashed in this repository earlier:
			remove the file manually to continue.
			Running tasks for *.vue [failed]
			→ × git add found some errors. Pleas... (show balloon)

  

posted @ 2022-08-11 11:38  卖糖纸的小糖果  阅读(474)  评论(0)    收藏  举报