查询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