I am running Ubuntu 18.04, as a Subsystem for Windows. I have done this in mutliple PCs and never had this problem. I try to to git clone <repo>
, and I get this:
Cloning into '<repo>'...
error: chmod on /mnt/c/Users/Efsta/Code/<repo>/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'
I tried the following:
❯ git config core.fileMode false
, with this resultfatal: not in a git directory
❯ git config --global core.filemode false
❯ git config --add --global core.filemode false
Nothing seems to work. I already tried a couple of answers here, but WSL seems a little bit more tricky. Anyone have any idea about how to solve this?
I have also tried everything in this question : https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes, nothing seems to work.
I had the same issue. Try this:
Change the drive letter to whatever one you're having the issue with.
You can automatically mount your Windows drives under WSL with the metadata option that allows apps, like git, to use chmod and fix this issue.
Edit
/etc/wsl.conf
(create it if it doesn't exist). Add the following:Then either:
wsl --shutdown
from PowerShell or CMD, and start WSL againwsl --terminate <distroName>
, and start it again,Then never worry about it again.
/mnt/c/Users/...
is on the Windows NTFS partition itself, and not within the WSL'sext4
formatted system. Therefore you have to treat it as you would an NTFS partition on a USB stick on an actual Ubuntu installation, and accept the limitations of NTFS.NTFS partitions do not support
chmod
or similar Linux permissions commands, and unlike in actual Ubuntu instalations which don't error but don't make any permissions changes, WSL doesn't relay this information back to you, it simply errors out as you see here.You cannot do a
git clone
sanely into the/mnt/c/...
space within WSL because of the Linux permission schemas andchmod
not working right. This is a limitation of WSL in its current form.I was having the same issue. My solution is to git clone my repo in the default WSL location (it works), and use Visual Studio Code to remote access my WSL's repos. That way you won't have to use /mnt/c at all.
Links: https://code.visualstudio.com/docs/remote/wsl