Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git clone behind corporate proxy

Tags:

git

I am working behind a corporate proxy, using a Windows 7 pc, and I would to use git hub, cloning some repo, doing pulls, commits and pushes.

I does not know the password of my proxy.

I can regularly download a repo via the button "Download ZIP" but I would use GIT via command line or via GitHub client app.

Thank you.

Edit

The repository whichI am trying to clone is a private repository and I am a contributor.

I receive the following message:

*fatal: unable to access 'https:***.git/': Connection timed out after 300043 milliseconds*

like image 586
giograno Avatar asked Jan 25 '16 08:01

giograno


4 Answers

If you don't want to set a global proxy, perhaps you just want to go via proxy for certain GitHub repo but not those hosted on your local server.

git clone --config http.proxy=http://proxy.local:3128 https://github.com/..../repo.git

If you want to add a proxy for a specific repo, after it was already cloned:

git config --add remote.[remote-name].proxy http://proxy.local:3128

(replace remote-name with the name of your remote such as origin)

like image 76
ETL Avatar answered Nov 08 '22 02:11

ETL


I does not know why I can regularly download the ZIP but I can't clone the repo. Why this difference?

Proxy is used to access the internet (which means to "go out" of your internal network). In your case is you can download ZIP but on the same time you can't pull code from GitHub it looks like you don't have the right permissions.

When you download ZIP you simply connecting to the internet and downloading file, while when connecting to git and trying to download code you need to use any of the git protocols.

Try to set up SSH key as described in the following answer and here.

###Summary:

  • If you can download files from the web you have an internet connection.

  • To set up git proxy configuration:

      git config --global http.proxy http://user:[email protected]:8080
      git config --global https.proxy http.proxy http://user:[email protected]:8080
    

But in your case you don't know the password so you should first try to set SSH keys and check if it works.

like image 30
CodeWizard Avatar answered Nov 08 '22 04:11

CodeWizard


Before running regular git commands, simply set proxy using below command.

git config --global http.proxy http://user:[email protected]:8080

like image 36
DataFramed Avatar answered Nov 08 '22 04:11

DataFramed


Given that the simple download works, it is likely that your computer is configured correctly for the proxy. You also need to make sure that the proxy configuration is shared with git on the command-line. This is usually done through environment variables such as http_proxy and https_proxy.


There are two options available when you click "Clone or download" to get the link. These are "Clone with HTTPS" and "Clone with SSH". In order to work with SSH keys, you need to use the "Clone with SSH" option.

The link provided for use with SSH has the following form: git@github.***.com:***.git

So to clone the repository, your command will look like:

git clone git@github.***.com:***.git

Also, make sure that you have copied the link correctly from the GitHub website. For example, the following intuitive translation from HTTPS may not work, and may instead respond with timeout errors similar to what was reported by the OP:

git clone git://github.***.com/***.git ## wrong form
like image 2
Brent Bradburn Avatar answered Nov 08 '22 03:11

Brent Bradburn