Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

windows - Git rename from index.lock to index failed

Using the GitHub Windows client I did a sync to pull remote changes to my local machine, but before finishing the sync, I ran out of disk space and the sync failed. Now I seem to have a bunch of local changes that are actually changes that were being pulled from origin. I tried to run git pull but got:

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

So now I'm trying to discard the local changes but I'm getting:

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

How can I clean this up? (I didn't have any local changes before starting the sync.)

Update

Can't seem to reset head..

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'.
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Looks like the following process had a lock on the .gitindex file:

ssh-agent.exe
C:UsersTomAppDataLocalGitHubPortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7inssh-agent.exe

I killed the process and ran git reset HEAD and looks like I'm back to normal now.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...