git

Git error 常见报错总结

Posted by Yuankun Li on 2022-12-07

Error 1 Failed to connect to github.com port 443 after xxx ms: Operation timed out

Error 2 HTTP/2 stream 1 was not closed cleanly before end of the underlying stream

是 git 默认使用的通信协议出现了问题,可以通过将默认通信协议修改为 http/1.1 来解决该问题。
$ git config --global http.version HTTP/1.1
git config --global http.postBuffer 157286400

Error git cherry-pick xxx fatal: bad object xxx

1
2
3
4
git checkout ABranch
# cherry-pick BBranch的一个commit
git cherry-pick 121c5f6402501dc05a9c8021ec39a52ce843d76d
fatal: bad object 121c5f6402501dc05a9c8021ec39a52ce843d76d

出现这个错误通常意味着你试图合并一个不存在的提交。git cherry-pick是本地特性,本地要有这个commit才可以被git cherry-pick。

  • 检查提交的哈希值是否正确;
  • 确保该提交存在于你的本地代码库中;
  • 如果提交是在远程代码库中,请确保已将其克隆到本地并且与远程代码库保持同步;
  • 如果仍然无法解决问题,可以尝试重新克隆代码库。
1
2
3
4
5
6
7
# 本地获取BBranch的commit
git checkout BBranch
git pull

git checkout ABranch
# cherry-pick BBranch的一个commit
git cherry-pick 121c5f6402501dc05a9c8021ec39a52ce843d76d


show git comment