Git Gem and other proxy setup issues under Linux

Source: Internet
Author: User
Tags using git

Github.com, as a programmer's code warehouse, we often use. But sometimes we can't link it directly through the Internet, only through proxies.

Here I have a proxy server, at first I thought the terminal set up the proxy environment on the line, it is set to add the following lines in your ~/.BASHRC:

[Python]View Plaincopy
    1. Export http_proxy="http://proxy-server:3128/"
    2. Export https_proxy="http://proxy-server:3128/"
    3. Export ftp_proxy="http://proxy-server:3128/"


Once set, use the following command to start it.

[Python]View Plaincopy
    1. SOURCE ~/.BASHRC


Then testing the wget is no problem, as follows:

But you can't use Git clone.

[Python]View Plaincopy
    1. git clone [email protected]:aborn/ulitcs.git

The reasons are known through these two articles: Access github.com and using Git over proxies on Windows via proxy

The preparation process is divided into the following steps:

1. Install the Socat and install it under Ubuntu using the following command

[Python]View Plaincopy
    1. sudo apt-get install Socat


2. Edit a script file named Git-proxy with the following contents

[Python]View Plaincopy
  1. #!/bin/sh
  2. # Use Socat-to-proxy git through an HTTP CONNECT firewall.
  3. # useful if you is trying to clone git://from inside a company.
  4. # Requires The proxy allows CONNECT to port 9418.
  5. #
  6. # Save This file as Gitproxy somewhere in your path
  7. # (e.g, ~/bin) and then run
  8. # chmod +x Git-proxy
  9. # git config--global core.gitproxy git-proxy
  10. #
  11. #
  12. # Configuration. Common proxy ports is 3128, 8123, 8000.
  13. _proxy=proxy-server
  14. _proxyport=3128
  15. exec socat STDIO proxy:$_proxy:$1:$2,proxyport=$_proxyport


3. Put the git-proxy in a directory, as I put it in/home/lisp/local/bin, and add the directory to the path

[Python]View Plaincopy
    1. CP git-proxy/home/lisp/local/bin/

Add the directory to path, add the following to ~/.BASHRC, and then Souce ~/.BASHRC

[Python]View Plaincopy
    1. Export path= $PATH:/home/lisp/local/bin

[Python]View Plaincopy
    1. SOURCE ~/.BASHRC

4. Modify ~/.gitconfig, add the following lines and agents

[Python]View Plaincopy
    1. Gitproxy = Git-proxy

The contents of my. gitconfig file are as follows:

[Python]View Plaincopy
    1. [Push]
    2. Default = Simple
    3. [User]
    4. Name = Aborn
    5. email = [email protected]
    6. [Core]
    7. Editor = Emacs
    8. Gitproxy = Git-proxy
    9. [HTTPS]
    10. Proxy = http://proxy-server:3128
    11. [HTTP]
    12. Proxy = http://proxy-server:3128

5. Download the conversion protocol file connect.c, click

Just download the connect.c file and compile

[Python]View Plaincopy
    1. Gcc-o Connect connect.c


Copy the compiled file connect to/home/lisp/local/bin

6. Modify the ~/.ssh/config to add the following line

[Python]View Plaincopy
    1. Proxycommand/home/lisp/local/bin/connect-h proxy-server:3128%h%p


The contents of my ~/.ssh/config file are as follows:

[Python]View Plaincopy
    1. Proxycommand/home/lisp/local/bin/connect-h proxy-server:3128%h%p
    2. Host github.com
    3. User [email protected]
    4. Port 443
    5. Hostname ssh.github.com


Note that the Connect file directory here is the same as the 5th-step directory.

When the above steps are complete, it will be done as follows:

[Python]View Plaincopy
    1. git clone [email protected]:aborn/ulitcs.git

[Python]View Plaincopy
    1. git push


Attention:

1. The above proxy-server based on your proxy, set to replace the IP address or domain name of your proxy server

2. The above connect.c file, the compiled connect file, and the Git-proxy file can also be downloaded from here connect.tar.gz and Git-proxy

3. My operating system is Ubuntu 14.04LTS

Git Gem and other proxy setup issues under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.