Git rename from index.lock to index failed
使用Github Windows客户端,我进行了同步,以将远程更改拉到本地计算机上,但在完成同步之前,磁盘空间不足,同步失败。现在,我似乎有一堆本地的变化,它们实际上是从源代码中提取出来的变化。我试图运行git pull,但得到:
1 2 3 4 5 6 7 8 9 10 11 12 | C:\Users\Tom\SourceLog [master +4 ~26 -0 !]> git pull Updating b3a86e1..5afd74f error: Your local changes to the following files would be overwritten by merge: SourceLog.Interface/IChangedFile.cs SourceLog.Interface/ILogEntry.cs ... Please, commit your changes or stash them before you can merge. error: The following untracked working tree files would be overwritten by merge: Lib/MSBuildExtensionPack/4.0.6.0/Ionic.Zip.dll Lib/MSBuildExtensionPack/4.0.6.0/MSBuild.ExtensionPack.dll ... Aborting |
所以现在我正在尝试放弃本地更改,但我得到:
1 2 3 4 | C:\Users\Tom\SourceLog [master +4 ~26 -0 !]> git checkout -- . Rename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) y Rename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) n fatal: unable to write new index file |
号
我怎么清理这个?(启动同步之前,我没有任何本地更改。)
更新似乎无法重置头部。
1 2 3 4 5 | C:\Users\Tom\SourceLog [master +4 ~0 -0 !]> git reset head Rename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) y Rename from '.git/index.lock' to '.git/index' failed. Should I try again? (y/n) n error: Could not write new index file. fatal: Could not reset index file to revision 'head'. |
似乎以下进程锁定了
1 2 | ssh-agent.exe C:\Users\Tom\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7\bin\ssh-agent.exe |
我取消了程序,运行了
在我的例子中,这是由使用来自管理和非管理命令提示的相同git repo引起的。当最后一个
我的解决方案是重新创建
1 2 | del .git\index git reset --mixed head |
。
当我试图执行时,我看到了这条
江户十一〔16〕号
对我来说,解决办法是以
具体来说,我使用优秀的Cmder应用程序作为非管理员,这导致出现重命名消息。通过以管理员身份运行Cmder,然后再次执行签出,它工作得很好。
Git 2.10(2016年第3季度,4年后)应改善Windows的情况
见Ben Wijen(
mingw : ensure temporary file handles are not inherited by child processesWhen the index is locked and child processes inherit the handle to
said lock and the parent process wants to remove the lock before the
child process exits, on Windows there is a problem: it won't work
because files cannot be deleted if a process holds a handle on them.The symptom:
号
1 2 | Rename from 'xxx/.git/index.lock' to 'xxx/.git/index' failed. Should I try again? (y/n) |
Spawning child processes with
bInheritHandles==FALSE would not work
because no file handles would be inherited, not even thehStdXxx handles inSTARTUPINFO (stdin/stdout/stderr).Opening every file with
O_NOINHERIT does not work, either, as e.g.git-upload-pack expects inherited file handles.This leaves us with the only way out: creating temp files with the
O_NOINHERIT flag. This flag is Windows-specific, however.
For our purposes, it is equivalent toO_CLOEXEC (which does not exist on
Windows), so let's just open temporary files with theO_CLOEXEC flag and
map that flag toO_NOINHERIT on Windows.
号
当我和师父重新平衡我的分支时,我似乎有问题。我的解决方案是关闭所有正在打开的解决方案,并将分支硬重置为原点,然后再次重新调整。
我用的是乌龟球。我刚打开一个新的Windows资源管理器,它修复了这个问题。(对于命令行git,可能只是打开一个新的shell)。
这可能是一个正确的问题,请尝试以管理员身份而不是以用户身份运行您的终端。为我工作
在存储在Google Drive文件夹中的项目中运行
我删除了
要么终止锁定文件的进程,要么如果是新的repo,删除.git文件夹
我和Git也有类似的问题。我的解决方案是通过Windows资源管理器在本地删除该解决方案,然后重新克隆存储库。这删除了本地存储在我的计算机上的所有文件,并导致
1 | Rename from '.git/..' to '.git/..' failed. Should I try again? (y/n) y |
。
离开。克隆了响应之后,我再次尝试了我的命令(在我的例子中是git commit),但失败并没有再次发生。
当我试图解决将功能分支合并到开发分支后发生的合并冲突时,问题出现了。
若要放弃本地更改,请转到
1 | git reset HEAD |
然后签出旧的提交,删除新的提交,然后再次拉。
1 2 3 | git checkout"hashOld" git branch -d"hashNew" git pull |
号
防病毒或OS Defender(例如Windows Defender正在运行)的原因。解决方案:关闭杀毒软件几分钟,然后添加、提交和推送。反病毒软件。它会起作用的。