Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to git clone in wsl?

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 [email protected]

And

ssh -i -T [email protected]

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?

like image 463
Azumi Avatar asked Jun 07 '20 12:06

Azumi


People also ask

Can I use git in WSL?

Git can be installed on Windows AND on WSL An important consideration: when you enable WSL and install a Linux distribution, you are installing a new file system, separated from the Windows NTFS C:\ drive on your machine.

Can I git clone on Windows?

To clone your Github repo on Windows. If Git is not already installed, it is super simple. Just go to the Git Download Folder and follow the instructions. Go to the current directory where you want the cloned directory to be added.


1 Answers

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.

like image 158
MrYutz Avatar answered Oct 16 '22 12:10

MrYutz