Meysam Meysam - 1 month ago 9
Git Question

Why "git clone" is trying to use https

I am running the following

git clone
command:

git clone http://gitlab.example.com/project/component.git


But I get this error:


Cloning into 'component'...

fatal: repository 'https://gitlab.example.com/project/component.git/' not found


As you can see, git is trying to clone the HTTPS url, which does not exist. Is there any configuration to disable this behavior?

p.s. I trying the following command:

$ git config --global url.http://gitlab.example.com/.insteadOf https://gitlab.example.com/


And here is the content of
~/.gitconfig
file:

[http]
sslverify = false
[url "http://gitlab.example.com/"]
insteadOf = https://gitlab.example.co


But I am still getting the same error when running
git clone
.

P.S.2: I am running this command in a docker container based on the jessie debian image. Could this be the source of the problem?

Answer

The problem was the DNS set in /etc/resolv.conf in docker container:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
search example.com

nameserver 8.8.8.8
nameserver 8.8.4.4

So I added the IP of the local gitlab to the following file:

/etc/hosts

192.168.20.112 gitlab.example.com

And the problem was fixed.