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
    

声明

作者: liyao

版权:本博客所有文章除特别声明外,均采用CCBY-NC-SA4.O许可协议。转载请注明!

最后更新于 2026-02-18 18:15 history