Search code examples
gitproxyazure-devopsgit-bashhttp-proxy

Git cloning URL vs Host Url


I am trying to clone a repository using Git-Bash to my account in a server. There is no access to the internet for this server, except to the the account "myvsaccount.visualstudio.com".

When cloning, even though I use the whole url "https://myvsaccount.visualstudio.com/Project/_git/repo/"

wireshark and fiddler tell me that the cloning to the URL above actually hits "myvsaccount.visualstudio.com". So I am guessing it should work. But I get the error:

fatal: unable to access 'https://myvsaccount.visualstudio.com/Project/_git/repo/': Could not resolve host: myvsaccount.visualstudio.com

As if the host does not exist or I don't have access. Do I have to open the server to the internet, now opening to all cloning URLs for it to work? I didn't think I would need to do that.

Also, I am using a proxy configuration [System.Net.WebRequest]::DefaultWebProxy = new-object System.Net,WebProxy($proxyUri, $true), but it is not helping.


Solution

  • You should config Git to use the proxy, the command to config as:

    git config --global http.proxy http://proxyUsername:[email protected]:port
    

    Then you can clone again to check if it can clone successful.

    More details, you can refer Configure Git to use a proxy and Getting git to work with a proxy server.