GIT:/.git/index.lock':文件存在

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11838793/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:19:57  来源:igfitidea点击:

GIT: /.git/index.lock': File exists

git

提问by sluggerdog

I am having a constant issue with one of my git repos. I keep getting the following error:

我的一个 git 存储库一直存在问题。我不断收到以下错误:

    fatal: Unable to create 'v:/path/to/files/.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 have tried: rm -f ./.git/index.lockas per another thread on stackoverflow but I get this error each time: rm: cannot unlink `./.git/index.lock': Permission denied

我试过:rm -f ./.git/index.lock根据 stackoverflow 上的另一个线程,但我每次都收到此错误:rm: 无法取消链接 `./.git/index.lock': Permission denied

When I close down aptana (I am using git in the terminal) I cannot delete the file still.

当我关闭 aptana(我在终端中使用 git)时,我仍然无法删除该文件。

Any ideas how to get around this?

任何想法如何解决这个问题?

Another thing to note is this git repo is very slow when I do occasionally get to commit within it (it allows me every 10 tries or so)

另一件要注意的事情是,当我偶尔在其中提交时,这个 git repo 非常慢(它允许我每 10 次左右尝试一次)

Thanks

谢谢

采纳答案by sluggerdog

The issue ended up being Aptana, everytime I ran this it would cause this error when I tried to commit in git.

问题最终是 Aptana,每次我运行它时,当我尝试在 git 中提交时都会导致此错误。

I stopped using aptana studio and I don't have this issue anymore.

我停止使用 aptana studio,不再有这个问题。

回答by Christopher

Sudo the command:

sudo命令:

sudo rm -f ./.git/index.lock

Both errors suggest index.lockis owned by another user. Run the rmas a superuser, then try your commands again. You might also consider setting core.sharedRepositoryto trueif that is, in fact, the case with your repo:

这两个错误都表明index.lock由另一个用户拥有。rm以超级用户身份运行,然后再次尝试您的命令。您也可以考虑设置core.sharedRepository为,true如果这实际上是您的回购的情况:

core.sharedRepository

When group (or true), the repository is made shareable between several users in a group (making sure all the files and objects are group-writable).

When all (or world or everybody), the repository will be readable by all users, additionally to being group-shareable. When umask (or false), git will use permissions reported by umask(2). When 0xxx, where 0xxx is an octal number, files in the repository will have this mode value. 0xxx will override user's umask value (whereas the other options will only override requested parts of the user's umask value). Examples: 0660 will make the repo read/write-able for the owner and group, but inaccessible to others (equivalent to group unless umask is e.g. 0022). 0640 is a repository that is group-readable but not group-writable.

See git-init(1).

False by default.

core.sharedRepository

当 group (或 true)时,存储库可在组中的多个用户之间共享(确保所有文件和对象都是组可写的)。

当全部(或世界或所有人)时,所有用户都可以读取存储库,此外还可以组共享。当 umask(或 false)时,git 将使用 umask(2) 报告的权限。当为 0xxx 时,其中 0xxx 是八进制数,存储库中的文件将具有此模式值。0xxx 将覆盖用户的 umask 值(而其他选项将仅覆盖用户 umask 值的请求部分)。示例: 0660 将使所有者和组可以读/写 repo,但其他人无法访问(等效于组,除非 umask 是例如 0022)。0640 是组可读但不可组写的存储库。

参见 git-init(1)。

默认为假。

回答by SEAFERN

Do this:

做这个:

rm index.lock

rm index.lock

followed by

其次是

git reset

重置

回答by Johan Van de Merwe

You also get this error if you are using Aptanta Git and other git clients, like f.e. TortoiseGit. So it is likely that this other Git software locked your Git, making it unavailable for Aptana.

如果您使用 Aptanta Git 和其他 git 客户端,例如 fe TortoiseGit,您也会收到此错误。所以很可能这个其他 Git 软件锁定了您的 Git,使其无法用于 Aptana。

回答by krishnaisdinesh

This may be an old reply but I'm hoping this is more useful on next who need this solution.

这可能是一个旧回复,但我希望这对下一个需要此解决方案的人更有用。

On linux/unix/gitbash/cygwin, try

在 linux/unix/gitbash/cygwin 上,尝试

rm -f .git/index.lock

On Windows Command Prompt, try:

在 Windows 命令提示符下,尝试:

del .git\index.lock

Hope that helps, I found this solution here: fatal: Unable to create 'project_path/.git/index.lock': File exists.

希望有所帮助,我在这里找到了这个解决方案:fatal: Unable to create 'project_path/.git/index.lock': File exists。

回答by Harshit Garg

In git version 2.11.0, .gitfolder may not include the index.lockfile. I figured out in the .git/refs/heads/folder contains a .lockfile and removing it using rmcommand works.

在 git 版本 2.11.0 中,.git文件夹可能不包含该index.lock文件。我发现.git/refs/heads/文件夹中包含一个.lock文件并使用rm命令将其删除。

Also be sure to kill the process that might be using git repo using ps -aef | grep gitand kill -9.

还要确保使用ps -aef | grep git和 终止可能正在使用 git repo 的进程kill -9

回答by Sandesh B S

If you are facing this issues in windows below steps help you out.. Go to particular path i.e, v:/path/to/files/ and enable show hidden files, folders and drivers. Then directly delete index.lock file inside the git folder (Which will be hidden previously)

如果您在 Windows 中遇到此问题,下面的步骤可以帮助您.. 转到特定路径,即 v:/path/to/files/ 并启用显示隐藏文件、文件夹和驱动程序。然后直接删除git文件夹里面的index.lock文件(之前会隐藏)

回答by khalid sayd

search for index.lock in your local repository and delete that file.

在本地存储库中搜索 index.lock 并删除该文件。