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.
This is caused when antivirus or OS defender (for example Windows Defender) is running.
The solution: turn off antivirus for several minutes make your add, commit and push.
Turn on antivirus.
It will work.
I got this error several times in a row when running git reset HEAD
in a project stored in a Google Drive folder, but after a few minutes the problem went away.
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.
To discard local changes, go
git reset HEAD
Then checkout your old commit, delete the new one, and pull again.
git checkout "hashOld"
git branch -d "hashNew"
git pull
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
git reset --mixed head
In my case I had to close the VS code which I opened with code .
from a WSL Ubuntu terminal.