ssh proxy pull and push github code

Posted

超越国界的github拉代码

最近github不太稳定,也许是github火车票助手事件的原因吧。但是还是要让我们可以用的来嘛。

用ssh用转发

ssh -C2qTnN -L 2222:github.com:22 ps@xxx.xxx.com

自定义本地的ssh地址

$ vi ~/.ssh/config

Host vpsgit
 HostName localhost
 Port 2222
 User git
 IdentityFile /Users/john/.ssh/id_rsa

保存wq!

检测是否成功

$ ssh vpsgit -T
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.

修改本地项目配置文件

$ vi .git/config 
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
[remote "origin"]
        fetch = +refs/heads/*:refs/remotes/origin/*
        url = git@github.com:xxx/xxxxx.git
[branch "master"]
        remote = origin
        merge = refs/heads/master

然后把自己的github的路径就行啦!如:url = vpsgit:xxx/xxxx.git

别一种方法

github hosts 完整版
vi /etc/hosts
207.97.227.239 github.com
207.97.227.252 nodeload.github.com
207.97.227.243 raw.github.com
204.232.175.78 documentcloud.github.com

此文章 短链接: http://dlj.bz/6yPIaq