分享免费的编程资源和教程

网站首页 > 技术教程 正文

设置git代理 git设置ssh代理

goqiw 2024-10-19 06:04:43 技术教程 42 ℃ 0 评论

以下以macOS为准.

  1. https访问仅为github.com设置socks5代理(推荐这种方式, 公司内网就不用设代理了, 多此一举):git config --global http.https://github.com.proxy socks5://127.0.0.1:1086其中1086是socks5的监听端口, 这个可以配置的, 每个人不同, 在macOS上一般为1086.设置完成后, ~/.gitconfig文件中会增加以下条目:
  2. [http "https://github.com"] proxy = socks5://127.0.0.1:1086
  3. ssh访问需要修改~/.ssh/config文件, 没有的话新建一个. 同样仅为github.com设置代理:
  4. Host github.com User git ProxyCommand nc -v -x 127.0.0.1:1086 %h %p
  5. 如果是在Windows下, 则需要个性%home%.ssh\config, 其中内容类似于:
  6. Host github.com User git ProxyCommand connect -S 127.0.0.1:1086 %h %p
  7. 这里-S表示使用socks5代理, 如果是http代理则为-H. connect工具git自带, 在\mingw64\bin\下面.

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表