【问题标题】:`Git` - update giving the error [.git/index.lock': File exists.]`Git` - 更新给出错误 [.git/index.lock': 文件存在。]
【发布时间】:2016-08-09 01:33:03
【问题描述】:

我的存储库位于git。在本地副本(我的系统)中,我对其中一个文件进行了一些更改。

我尝试将该文件更新到git 存储库。为此,我正在运行以下命令:

git commit -a "text file updated"

但我收到如下错误:

$ git commit -a
fatal: Unable to create 'D:/Projects/gitProjects/color-palette/.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.

这里有什么问题?以及如何解决这个问题? 我所做的是将文件从本地更新到 git 的正确方法吗?

【问题讨论】:

  • 尝试将 index.lock 文件移动到存储库之外的位置,然后重试
  • git或本地机器上。你能解释一下这里到底有什么问题吗?
  • 我猜锁定文件已损坏。删除它(或按照我的建议将其移动以进行备份和恢复)可能会解决问题
  • 这是我的 repo https://github.com/3gwebtrain/color-palette - 在该文件嵌套删除的位置?
  • 问题出在您本地克隆的存储库中,而不是在服务器上。锁定文件仅存在于您的本地驱动器中

标签: git github git-commit


【解决方案1】:

问题是你只有一个锁文件。

如果你删除它,你可以删除它获取远程存储库:

# delete the lock file
rm -rf .git/index.lock

# update the local repository
git fetch --all --prune

执行此操作后,您的本地存储库将使用远程存储库进行更新。

提交您的更改,然后您可以将更改拉入您的分支

# add all the changes
git add . 

git commit -m "Message"

# pull the changes which were added to the remote
git pull origin <branch name>

如果删除索引不起作用怎么办?

在这种情况下,您应该尝试重新克隆您的项目,一旦您将所需的更改文件复制到第二个克隆上,然后提交它们。

【讨论】:

    猜你喜欢
    • 2012-08-04
    • 2016-04-14
    • 1970-01-01
    • 2011-12-13
    • 1970-01-01
    • 2013-05-12
    • 1970-01-01
    • 2012-12-09
    • 1970-01-01
    相关资源
    最近更新 更多