git Roadmap

Git / SSH 排障专题

Git / SSH 排障专题:聚合 SSL certificate problem、Permission denied (publickey)、代理配置、凭证存储、远程仓库地址修改和合并冲突解决等常见 Git 问题的完整排障路径与命令模板。

Git 排障先区分 HTTPS、SSH、代理和证书四个链路,再查看配置来源确认是 system/global/local 哪一级覆盖了当前仓库,保留 verbose 输出但不要泄露 token 和私钥,避免在错误链路上反复改配置。

gitsshhttpsproxycredentialmerge
排障 / 命令13
精选入口4
工具 / 速查5
最近更新2026-07-12

Troubleshooting Path

推荐排障路线图

提交问题 →
  1. 01

    先确认协议和认证链路

    用 git remote -v 看当前仓库走 HTTPS 还是 SSH,两套链路的排查命令和配置项完全不同,不要混着改。

  2. 02

    再查代理和证书配置

    全局代理、公司 CA、本地抓包代理和过期证书都会让 Git 报 SSL 或连接失败,用 git config --show-origin 确认配置来源。

  3. 03

    继续验证密钥是否被真正使用

    密钥文件存在不代表 SSH 提交了它,用 ssh -G 查看最终配置、ssh -T 验证平台账号、ssh -vvv 看密钥协商过程。

  4. 04

    最后处理凭证存储和合并冲突

    凭证 helper 配置不当会导致反复输密码或 token 失效,合并冲突时先理解冲突标记再分阶段 git add,不要盲目 git merge --abort。

Before You Change

执行前检查

  • 排查前用 git remote -v 确认协议,HTTPS 和 SSH 排障路径不同
  • 不要把 sslVerify=false 作为永久配置,应使用正确的 CA 证书路径
  • SSH 排障时用 ssh -vvv 保留完整协商过程,但注意脱敏私钥信息
  • 修改全局配置前先确认影响范围,避免污染其他仓库

Start Here

优先阅读

Latest Updates

最近更新

All Runbooks

全部相关内容

排障

curl 使用代理连接超时排查

curl -x 通过 HTTP/SOCKS5 代理访问超时或 Failed to connect to proxy 时,用 curl -v 定位卡在代理还是目标站,区分 http 与 socks5/socks5h 协议、代理端 DNS 解析和 NO_PROXY 环境变量是否排除了目标域名。

curlproxytimeout
排障

Git 修改远程仓库地址

更换 GitHub、GitLab 或私有 Git 仓库地址时,用 git remote set-url origin <new-url> 一步替换远程 URL,配合 git remote -v 验证,再介绍 add upstream、remove、rename 等相关操作,改地址不会影响分支追踪关系。

gitremoteurl
排障

Git 保存用户名密码的正确方式

Git 通过 HTTPS 拉代码每次都要输入用户名密码时,配置 credential.helper 选择 store 明文、cache 内存缓存或 Windows 下的 manager 加密存储,SSH 仓库改用密钥认证,避免把密码明文写在 remote URL 里。

gitcredentialpassword
排障

Git 合并冲突解决流程

git merge 或 git rebase 出现冲突时,用 git status 列出冲突文件,逐个手动解决 <<<<<<< ======= >>>>>>> 标记,再 git add 标记为已解决,merge 场景 git commit、rebase 场景 git rebase --continue,需要撤销用 --abort。

gitmergeconflict
排障

Git SSL certificate problem 解决方法

Git clone/pull 报 SSL certificate problem: unable to get local issuer certificate 时,用 GIT_CURL_VERBOSE=1 打印真实证书链,确认是否走了公司代理,把代理 CA 加入 http.sslCAInfo 或系统信任,避免直接关闭 sslVerify。

gitsslproxy
排障

Nginx 301/302 跳转配置与常见问题

Nginx 配置 HTTP→HTTPS、旧域名迁移或路径重写时,用 return 301 https://example.com$request_uri 做永久跳转、302 做临时跳转,避免 rewrite + if 组合,配合 curl -I -L 验证 Location 头,跳转循环则检查 server 块之间是否互指。

nginx301302
排障

HTTPS 混合内容(Mixed Content)排查

HTTPS 页面加载 http:// 资源被浏览器提示 Mixed Content blocked 时,用 F12 Console 定位被阻止的 script/stylesheet/image,区分 active/passive 混合内容并逐个改成 https 或相对协议,也可在 Nginx 加 CSP upgrade-insecure-requests 兜底。

nginxhttpsmixed-content
排障

Nginx HTTPS 证书过期与链不完整排查

浏览器提示 NET::ERR_CERT_DATE_INVALID、curl 返回 SSL certificate problem: certificate has expired 时,用 openssl s_client -connect 查线上实际证书 dates,再对比服务器文件、确认 ssl_certificate 指向 fullchain.pem 且 certbot 续期后 reload 了 Nginx。

nginxsslhttps
排障

Nginx 反向代理 WebSocket 配置与排障

Nginx 反向代理 WebSocket 出现 1006 异常关闭、连接建立后很快断开或收不到消息时,必须设置 proxy_http_version 1.1、透传 Upgrade 与 Connection: upgrade 头,并调大 proxy_read_timeout 让长连接不被 60s idle 超时断开,握手成功会返回 101。

nginxwebsocketproxy
排障

SSH Permission denied (publickey) 排查流程

ssh 或 git 拉代码报 Permission denied (publickey) 时,先用 ssh -vvv 看客户端提交了哪把 key 和服务端 Authentications that can continue,再核对 authorized_keys 内容、~/.ssh 目录 700 与 authorized_keys 600 权限,云服务器还要检查 sshd_config 和安全组。

sshpublickey权限
命令

Git 配置和取消代理命令

Git 配置和取消 HTTP/HTTPS/SOCKS5 代理的常用命令,git config --show-origin --get-regexp proxy 找出代理配置来自 system/global/local 哪一级,http.proxy 只影响 HTTP 仓库,SSH 仓库需要单独配置 ssh ProxyCommand 或 IdentityFile。

gitproxyconfig
命令

openssl 检查 HTTPS 证书命令

openssl s_client 检查线上 HTTPS 证书的常用命令,openssl s_client -connect example.com:443 -servername 触发 SNI 拿到真实证书,用 openssl x509 -noout -dates -issuer -subject 提取有效期与颁发者,-showcerts 查看完整证书链。

opensslsslhttps
命令

SSH 生成密钥和分发公钥命令

SSH 生成密钥与分发公钥的常用命令,ssh-keygen -t ed25519 生成推荐算法密钥,ssh-copy-id 一键分发公钥到 authorized_keys,配合 ~/.ssh 700、authorized_keys 600 权限,多账号在 ~/.ssh/config 里用 Host + IdentityFile 区分。

sshkeygenauthorized_keys