This is in WSL2 running ubuntu 20.04.
I am trying to use an existing set of code that is on my computer and put it into an empty repository I have on gitlab that is set to HTTPS. It is not set up for SSH and cannot be switched to SSH. All the answer I've seen have been for SSH and have not worked.
This is what I did:
git init
git remote add origin https://username@url/repository.git
git config http.sslVerify "false"
git commit -m "message"
git push -u origin master
Which gave the error fatal: unable to access [url] could not resolve host [host]
This is what I've tried since:
git set-origin https://username@url/repository.git
git set-url origin https://username@url/repository.git
All have given the same error after when trying to push again. It hasn't given me prompts to login like it does when doing
git -c http.sslVerify=false clone https://username@url/repository.git
Is there anyway to get it to verify this way or do I have to just clone the repository elsewhere and copy everything over?
Thank you!
CodePudding user response:
A few days later and I have figured out the answer.
In WSL, I didn't have the /etc/resolv.conf set up correctly. Here is the steps I took to set it up.
In windows, ipconfig.exe /all
take note of all of the DNS servers that WSL needs access to.
Create or edit /etc/wsl.conf to say
[network]
generateResolvConf = false
Check to see if /etc/resolv.conf is set to immutable lsattr /etc/resolf.conf
WSL will often have them set to immutable and if it is set to immutable, you won't be able to edit it. To make it no longer immutable type chattr i /etc/resolf.conf
.
After that, add all of the DNS IPs from windows into the resolv.conf file like this namespace 0:0:0:0
. Keep namespace 8:8:8:8
at the end as a backup in case it fails. 8:8:8:8 is google and allows you to check to see if you have internet at all by using ping google.com
or if you are completely offline.
For this to go into effect you have to close all WSL windows you have open. Then, in powershell or command prompt you need to type wsl --shutdown
for your changes to go into effect.