因为我们的学校内部网络使用了代理,所以在安装Moses的时候有个小麻烦,我们的 http 代理服务器无法通过 git 协议下载 mose所需的代码,也就是说可以 git clone https:// 这样克隆代码,但是不能使用 git 协议 git clone git://。如何让 git 使用 http 代理服务器呢?

如果是 git clone http:// 或 git clone https:// 的话直接把代理服务器加到环境变量就可以了:

$ export http_proxy="http://username:password@proxy.waseda.****:8080/"
$ export https_proxy="http://username:password@proxy.waseda.****:8080/"

如果是 git clone git:// 的话麻烦一些(可能有的 git 源不提供 http/https 的方式),需要先安装 socat,然后创建一个叫做 gitproxy 的脚本并填上合适的服务器地址、端口号等,最后配置 git 使用 gitproxy 脚本:

$ sudo apt-get install socat

$ sudo gedit /usr/bin/gitproxy

#!/bin/bash

PROXY=yourproxy
PROXYPORT=8080
PROXYAUTH=username:password
exec socat STDIO PROXY:$PROXY:$1:$2,proxyport=$PROXYPORT,proxyauth=$PROXYAUTH


$ sudo chmod +x /usr/bin/gitproxy $ git config --global core.gitproxy gitproxy