'Cannot do a git pull, unable to write to pack directory
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.
Solution 1:[1]
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.
- Check if you have permissions, i.e. if you execute the
git pull
command via CLI, make sure the CLI instance has proper authorization level. In case of Windows this would be "Run as administrator" - Disk space. This was already mentioned in the comments by @sk_pleasant and is mentioned here: Git 'fatal: Unable to write new index file' - however you already did exclude that
- If it's a file - does it already exist? Note: e.g.
.git
can be a file OR a folder! Either is allowed from the perspective of the Windows filesystem!- Does
.git/objects/pack/pack-a1106a9b7ac7c2f544e979878a1468e633e5fb94.pack
already exist? - If so, is it used by another process or is locked for some other reason?
- Check by attempting to do the modifications which are attempted by
git pull
manually instead, i.e. attempt to create the file by hand
- Does
- If you are using Git Bash, make sure to quit all instances. In the past I observed Git Bash being able to lock whole folders after having visited them (even if the active instance does no longer point into the folder)
For 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.
Solution 2:[2]
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.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Paul |