Reputation: 982
I receive the following error when doing a simple git pull
:
remote: Azure Repos
remote: Found 357 objects to send. (13 ms)
Receiving objects: 100% (357/357), 915.27 KiB | 614.00 KiB/s, done.
Resolving deltas: 100% (232/232), completed with 44 local objects.
error: unable to write file .git/objects/pack/pack-a1106a9b7ac7c2f544e979878a1468e633e5fb94.pack: Permission denied
fatal: cannot store pack file
fatal: index-pack failed
This appears to be a new problem but as far as I can figure out, nothing fundamental has changed on my machine since my previous successful pull.
I have tried to run the shell as admin but this too does not make a difference.
I am also able to create and delete files as per normal into this folder.
Upvotes: 3
Views: 18131
Reputation: 1
for me running this command helped to identify broken refs:
git fsck --full
then manually remove broken refs:
Remove-Item .git\logs\refs\remotes\origin\user\branch
,
Remove-Item .git\refs\remotes\origin\user\branch
Upvotes: 0
Reputation: 4386
In my case, I had installed a new version of Git, which had prompted me to restart my machine. I ignored it and then promptly forgot about the pending restart. Once I did that, the error went away.
Upvotes: 0
Reputation: 61
I got following error when trying to add file to stage :
error: unable to write file .git/objects/7a/e1a47cd4025d6d746721503ea5496de30ba3d7: Invalid argument
error: gradle.properties: failed to insert into database
error: unable to index file 'gradle.properties'
fatal: updating files failed
I got around it by closing the file from notepad++ and modified it on Git Bash directly.
Upvotes: 0
Reputation: 31
As you can see in the output of git pull
the line which shows the error is:
error: unable to write file .git/objects/pack/pack-a1106a9b7ac7c2f544e979878a1468e633e5fb94.pack: Permission denied
To fix it run git gc
("gc" stands for garbage collection).
In my case git gc
outputs:
error: bad ref for .git/logs/refs/remotes/origin/HEAD
error: bad ref for .git/logs/refs/remotes/origin/master
fatal: bad object refs/remotes/origin/master
fatal: failed to run repack
to solve it follow this answer
Upvotes: 3
Reputation: 1798
In the past I ran into similar problems as well. Several checks should be done before jumping to more advanced solutions. This is just a checklist taylored for your specific scenario.
git pull
command via CLI, make sure the CLI instance has proper authorization level. In case of Windows this would be "Run as administrator".git
can be a file OR a folder! Either is allowed from the perspective of the Windows filesystem!
.git/objects/pack/pack-a1106a9b7ac7c2f544e979878a1468e633e5fb94.pack
already exist?git pull
manually instead, i.e. attempt to create the file by handFor me personally I found the most common issue for being unable to change files was them being used by some other process. In my case most commonly such processes are compilers, active CLI instances, archive managers.
In case you still have the previous clone you might check and see if any of these apply to your case.
Upvotes: 6
Reputation: 982
So I hesitantly post this as an answer but, alas, it is one. I deleted my repo and re-cloned and now I can git pull
again.
Upvotes: 3