本页导航
article
git设置代理
AI摘要
本文介绍了如何为Git配置代理以解决网络访问问题。主要步骤包括开启Clash代理、在系统网络设置中手动配置代理,以及通过Git命令设置和验证代理。文章还提供了取消代理的方法,并针对VSCode推送报错等常见问题,给出了检查SSH密钥、生成新密钥及在GitHub配置的解决方案。
git设置代理
1、打开clash开启代理
2、系统设置代理
网络和Internet设置 -> 代理 -> 手动设置代理
3、git设置代理
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
git config --global https.proxy socks5 127.0.0.1:7890
git config --global https.proxy socks5 127.0.0.1:7890
4、查看git代理是否设置成功
git config --global -l
git config --global --get http.proxy
git config --global --get https.proxy
5、git取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy
.gitignore 新加忽略文件,发现忽略的文件还会提交。
git rm -r --cached .
git add .
git commit -m 'update .gitignore'
常见问题
vscode推送报错
The authenticity of host 'github.com (ip)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)?
解决办法
打开 Git Bash
检查现有的 SSH 密钥:
$ ls -al ~/.ssh
如果您已经拥有它们,您将看到:
- id_rsa.pub
- id_ed25519.pub
如果没有,请生成一个(按 Enter 接受默认文件位置):
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
要将密钥复制到剪贴板:
clip < ~/.ssh/id_rsa.pub
前往 Github/Settings/SSH 和 GPG 密钥/新 SSH 密钥上的帐户
将您的密钥粘贴在那里
接下来输入:
git remote
如果你看到 origin,请将其删除:
git remote remove origin
继续 GitHub repo 页面上提供的最后 2 个步骤…
git remote add origin git@github.com:USERNAME/REPONAME.git
git push -u origin main
最后更新于 2026-02-18 18:15