3

I am running the command git gc on a git repository and am getting the error Deletion of directory '.git/objects/01' failed.

I am running the command in Git Bash on Windows 10.

I am pretty sure it isn't another process using the folder as I able to remove the directory within the same Git Bash shell via the rm -r command. Upon rerunning git gc I am informed Deletion of directory '.git/objects/02' failed.

Any ideas?

ryarco
  • 101
  • 1
  • 5
  • Is your current user the owner of all the files in the `.git` folder? You can check it with `ls -l .git`. You can find your username e.g. with `whoami`, `echo $USER` or `id -u -n`. You can change the owner e.g. with `sudo chown -R "$whoami" .git`, check https://askubuntu.com/a/49187/757721 – Michael H. May 04 '19 at 10:56
  • Thanks for the comment @MichaelH. I checked and I do own the files. Note that I am able to delete the folder by using `rm -r` within the same shell. – ryarco May 04 '19 at 11:52
  • Same here, I'm the owner. Why is it failing? – Darkgaze Mar 29 '20 at 17:47

1 Answers1

0

I have got the same issue in Windows 10 using git version 2.25.1.windows.1 Actually it is a test repository.

In my case all the directories with issues are empty and git asks for permission 3 times for each directory.

I solved this with:

set GIT_ASK_YESNO=false
git gc

As suggested at Unlink of file Failed. Should I try again? by andhdo. This solve the messages but leaves empty folders in disk.