Git rename from index.lock to index failed

Looks like the following process had a lock on the .git\index file:

ssh-agent.exe
C:\Users\Tom\AppData\Local\GitHub\PortableGit_8810fd5c2c79c73adcc73fd0825f3b32fdb816e7\bin\ssh-agent.exe

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


In my case, this was caused by using the same Git repo from both admin and non-admin command prompts. When last git pull was from admin cmd, the index was created by it, and then non-admin cmd had insufficient permissions to modify it.

My solution was re-creating the index (while keeping the worktree intact):

del .git\index
del .git\index.lock
git reset --mixed head