查询git配置
git config -l
git代理
设置http代理
git config --global http.proxy http://127.0.0.1:8080
git config --global https.proxy https://127.0.0.1:8080
设置socks5代理
git config --global http.proxy 'socks5://127.0.0.1:1080'
git config --global https.proxy 'socks5://127.0.0.1:1080'
取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
密钥
生成单个密钥
生成密钥命令,如下
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
将密钥的公钥copy到git站点的配置

测试是否成功
ssh -T git@github.com
生成多个密钥
生成两个不同的密钥命令,如下
ssh-keygen -t rsa -C "xxxxxxx@qq.com" -f "id_rsa_github"
ssh-keygen -t rsa -C "xxxxxxx@qq.com" -f "id_rsa_gitee"
配置C:\Users\登录用户名\.ssh\config,不同的git地址路由到对应的密钥
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee
测试是否成功
ssh -T git@github.com
ssh -T git@gitee.com
常用命令

下载项目源代码
git clone git@github.com:camellibby/java_demo.git
拉取新代码
git pull
上传代码
git push
本文详细介绍了如何查询和设置Git配置,包括HTTP和SOCKS5代理的设定及取消,以及SSH密钥的生成与管理。针对不同的Git服务,如GitHub和Gitee,配置了不同的SSH密钥,并提供了测试连接的步骤。此外,还列举了一些常用的Git命令,如克隆、拉取和推送代码。

184

被折叠的 条评论
为什么被折叠?



