How to access git repository through http proxy?

  1. Install socat. E.g., on SUSE:
    zypper in socat
    
  2. Download this file:
    #!/bin/sh
    # Use socat to proxy git through an HTTP CONNECT firewall.
    # Useful if you are trying to clone git:// from inside a company.
    # Requires that the proxy allows CONNECT to port 9418.
    #
    # Save this file as gitproxy somewhere in your path (e.g., ~/bin) and then run
    #   chmod +x gitproxy
    #   git config --global core.gitproxy gitproxy
    #
    # More details at http://tinyurl.com/8xvpny
    
    # Configuration. Common proxy ports are 3128, 8123, 8000.
    _proxy=proxy.yourcompany.com
    _proxyport=3128
    
    exec socat STDIO PROXY:$_proxy:$1:$2,proxyport=$_proxyport
    
  3. Rename its name as gitproxy, and modify _proxy and _proxyport.
  4. Copy it into your PATH , e.g., /usr/bin.
  5. Switch to the directory which contains gitproxy, and execute the following commands:
    # chmod +x gitproxy
    # git config --global core.gitproxy gitproxy
    
  6. Now, git clone git://... will work!

 

Install git-email on RHEL 7.0

The RHEL 7.0 ISO doesn’t provide git-email rpm package by default. Because the git rpm provided by ISO file isgit-1.8.3.1-4.el7.x86_64.rpm, you should download the same version here, and install it:

[root@linux ~]# rpm -ivh git-email-1.8.3.1-4.el7.noarch.rpm
warning: git-email-1.8.3.1-4.el7.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
error: Failed dependencies:
        perl(Authen::SASL) is needed by git-email-1.8.3.1-4.el7.noarch
        perl(Net::SMTP::SSL) is needed by git-email-1.8.3.1-4.el7.noarch

From the error message, we know also need to use yum to install perl-Net-SMTP-SSL and perl-Authen-SASL packages:

[root@linux ~]#yum install perl-Net-SMTP-SSL
[root@linux ~]#yum install perl-Authen-SASL

Done!

 

How to install git on SUSE

On SUSE, when you want to install git, execute “zypper in git“:

nanxiao:~ # zypper in git
Loading repository data...
Reading installed packages...
'git' not found in package names. Trying capabilities.
No provider of 'git' found.
Resolving package dependencies...

Nothing to do.

You should use “zypper in git-core“:

nanxiao:~ # zypper in git-core
Loading repository data...
Reading installed packages...
Resolving package dependencies...

The following 2 NEW packages are going to be installed:
  git-core perl-Error

2 new packages to install.
Overall download size: 3.2 MiB. Already cached: 0 B. After the operation, additional 19.5 MiB will be used.
......

Enjoy git now:

nanxiao:~ # git
usage: git [--version] [--help] [-C <path>] [-c name=value]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

The most commonly used git commands are:
......