Git Couldn't stash Unable to create index.lock File exists.

今天在使用 Git ,当我 pull 时,失败了,日志为:

Couldn't save uncommitted changes.
        Tried to save uncommitted changes in stash before Update, but failed with an error.
        Couldn't stash file://**: Unable to create '../.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.

  它显示当前仓库已经有一个 git 进程在运行了,让我们关掉所有进程后重试,但是我的项目刚刚才打开,也没有运行 git 命令,而且打开了任务管理器,也没有发现多的 git 进程。

  我看到 git 命令失败的原因是因为 .git 目录下的 index.lock 文件已经存在了,那么这个 index.lock 文件是干啥的呢?是为了防止你对同一个仓库在同时进行多个操作,在一些耗时的 git 操作时自动生成的。那为什么第一次打开项目,没有进行过 git 操作也有这个文件呢?其实是有可能你上一次进行 git 操作时,git 操作还没有完成,你就强行关闭了,导致这个文件没有被自动删除。

  那我们就手动删除就可以了,我们打开这个项目的根目录,打开 /.git 目录,删除 index.lock 文件就可以。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值