「Git」- 常见错误、常见问题

在 Windows 中,执行特别慢

问题描述:
在 Windows 中,Git Bash Here,当窗口启动后,命令提示符要经过数秒才能显示,并且执行(比如 git status 等等)命令需要数秒才能显示。

原因分析:
git commands running slow as hell · Issue #1129 · git-for-windows/git · GitHub
Git commands have a 2-3 second delay before returning to the prompt · Issue #1070 · git-for-windows/git · GitHub
2.11.1 slow enough to make it unusable in Windows 10 x64 – upgraded from 2.9 lighting fast · Issue #1071 · git-for-windows/git · GitHub

解决方案:
针对我们的问题,我们通过 Nvdia 驱动提供的「Nvdia 控制面板」将「图形处理器」设置为「高性能 NVIDIA 处理器」来进行解决该问题(我们未深究,也不是很懂,可能并不适用于其他场景)。

fatal: refusing to merge unrelated histories

Git refusing to merge unrelated histories on rebase

使用--allow-unrelated-histories选项。

fatal: index file smaller than expected

git – index file smaller than expected – Stack Overflow

原因分析:我们猜测是异常宕机,导致正常执行的 git 命令突然退出,而导致 .git/index 文件损坏;

解决方案:删除 .git/index 文件;

关于 TLS 的错误

Problem with the SSL CA cert (path? access rights?)

GIT ERROR: PROBLEM IN THE SSL CERTIFICATE, VERIFY THAT THE CERTIF. CA IS OK | Robert Menetray

问题描述:

# git push origin master 
fatal: unable to access 'https://git.example.com/foo.git/': Problem with the SSL CA cert (path? access rights?)

解决方案:

git config --global http.sslVerify false

… CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none …

问题描述:

# git push origin master 
fatal: unable to access 'http://example/foo.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

解决方案:

// 或,更新 CA 证书
apt-get install ca-certificates

// 或,禁用 SSL 校验
git config --global http.sslVerify false