从index.lock重命名为索引失败

使用GitHub Windows客户端,我做了同步以将远程更改提取到本地计算机,但在完成同步之前,我的磁盘空间不足,同步失败。 现在,我似乎有一堆本地更改,实际上是从原点拉出的更改。 我试图运行git pull但得到:

C:UsersTomSourceLog [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

所以现在我试图放弃本地更改,但我得到:

C:UsersTomSourceLog [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

我怎样才能清理它? (在开始同步之前,我没有任何本地更改。)

更新

似乎无法重置头..

C:UsersTomSourceLog [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'.

看起来像下面的过程对.gitindex文件有一个锁:

ssh-agent.exe
C:UsersTomAppDataLocalGitHubPortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7binssh-agent.exe

我杀死了这个进程并运行git reset HEAD ,现在看起来我恢复了正常。


我的解决方案是重新创建index (同时保持工作树完整):

del .gitindex
git reset --mixed head

要放弃本地更改,请继续

git reset HEAD

然后检查您的旧提交,删除新提交,然后再次提取。

git checkout "hashOld"
git branch -d "hashNew"
git pull
链接地址: http://www.djcxy.com/p/18851.html

上一篇: Git rename from index.lock to index failed

下一篇: How to revert changes to previous state