【随笔记】MacOS系统下设置Git及配置代理详细记录

记录在windows、linux、macOS下配置Git,及给Git配置代理的详细步骤。

生成 ssh 秘钥对

# 生成 ssh 秘钥对,一路回车
$ ssh-keygen -t rsa

# 查看公钥
$ cat ~/.ssh/id_rsa.pub

配置用户名 邮箱

# 设置用户名
$ git config --global user.name "your name"

# 设置密码
$ git config --global user.email "your email"

以上配置三种系统都是一样的。

Windows 代理设置

1.安装git找到安装目录下的ssh_config文件

x64 C:\Program Files\Git\etc\ssh

x86 C:\Program Files(x86)\Git\etc\ssh

2.添加配置如下

Host ServerIP

IdentityFile “~/.ssh/id_rsa”

ProxyCommand /mingw64/bin/connect.exe -H ProxyIP:ProxyPort %h %p

如果是x86的版本需要修改mingw64为mingw32

MacOS Linux 设置代理

  1. 安装 connect
# 下载 connect 源码
$ git clone https://github.com/moonagic/connect.git

# 编译 connect 源码
$ cd connect && make

# 将编译后的 connect 二进制文件拷贝到 bin 目录
$ cp connect /usr/local/bin
  1. 修改 ~/.ssh/config 如下
# ServerIP Git服务器IP
# ProxyIP:ProxyPort 代理服务器IP与Port
Host ServerIP
  IdentityFile "~/.ssh/id_rsa"
  ProxyCommand connect -H ProxyIP:ProxyPort %h %p
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值