fatal: could not create work tree dir <repo-name>. File exists

Viewed 1156

Running git clone <repo> results in fatal: could not create work tree dir <repo-name>. File exists.

This is unexpected.

2 Answers

You might have the path open somehow.

Make sure you don't have any other terminals/windows open to that folder. Check your other "virtual desktops" if you have any. You may have powershell open on the folder, and then WSL-ed or remoted into another computer.


I just had this happen to me. I deleted the folder for a fresh pull, everything told me the folder was gone, but I had a terminal with the path open even though it didn't exist. This might be a Windows only problem.

Just a tip for future me, and anyone else who might be close to loosing another 15 minutes of their life.

If you are working with .devcontainer in VSCode, check if a container is running into docker (docker ps -a) and remove it (docker stop {container_id} && docker rm {container_id}).

Related