I try to clone a repo from a brand new Windows Install with wsl (Ubuntu 20.04). What I did: generate SSH key and add public key to both github and framagit. Tried
ssh -i -T git@github.com
And
ssh -i -T git@framagit.org
Both of them saied "Hello my pseudo, you're authentified"
But when I try to clone I have the following: Without sudo:
Cloning into 'testaaa'...
error: chmod on /mnt/d/dev/dev/testaaa/.git/config.lock failed: Operation not permitted
fatal: could not set 'core.filemode' to 'false'
With sudo:
Cloning into 'testaaa'...
ssh: connect to host framagit.org port 22: Network is unreachable
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
What can I do to solve my issue?
You don't want to use sudo
here, and in general there's no reason to need it with Git unless the repository you're working with is owned specifically by root
.
The problem you're seeing is that you're using a Linux Git, which expects standard Unix permissions to work, on a file system (NTFS) that does not support them. Git will try to set the permissions appropriately when it rewrites the lock file which it will rename into places as the config file, but it can't do so, and it fails. Git for Windows doesn't have this problem because it maps these permissions differently from WSL, which just always returns an error.
You can try a couple of things:
git init
again in the repository after cloning.git init
on the Windows drive and then do a git remote add origin YOUR-REMOTE
and a git pull origin master
(or whatever your branch is called). It's possible that the last one may not work any better than what you have now, since git init
may fail the same way.
You can fix this by following this guide . Summary below.
From a WSL prompt:
sudo vim /etc/wsl.conf
Add these lines:
[automount]
options = "metadata"
Save the file, shutdown wsl from a PowerShell prompt:
wsl --shutdown
Re-open a wsl terminal. You should see files owned by your user now instead of root. You can now git clone, chmod, chown etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.