这篇文章将会记载一些在运用 Git 进程中经常会遇到的过失及其解决办法(继续更新)


过失 1

> git push
# fatal: unable to access 'https://github.com/xxx/xxx.git/': Failed to connect to github.com port 443: Timed out

【解决办法】

这种状况可能是网络不坚http协议定引起的,能够查验替换网络环境或许多试几回

过失 2

> git push
# fatal: repositorgitlaby 'https://github.com/xxx/xxx.git/' notgithub官网 found

【解决办法】

这种状况可能是权限验证过失引起的,能够查验卸载 Git 凭据管理器后重装

> git credential-manager uninstgithub怎样下载文件all # 卸载

> git credential-manager install   # 装置

过失 3

> githttps和http的差异 push
# fatal: unhttp 404able to access 'https://githttp 500hub.com/xxx/xgit指令xxgithub永久回家地址.git/': OpenSSL SSL_rhttps域名ead: Connegithub打不开ction was reset, errno 10054

【解决办法】

这种状况可能是 SSL 验证失利导致的,我们能够直接制止 SSL 验证

git config --global http.sslVerify "fhttps域名alse"

官网上github直播渠道永久回家关于 http.sslVerify 的阐明如下:

Whgithub敞开私库ether to verify the SSL certificate when fetching or pushing over HTTPS.giti Defaults to true. Can be overgiti是什么牌子ridden by the GIT_SSL_NO_VEgithub是干什么的RIFY environment variable.

通过 HTTPS 抓取和推送时是否进行 SSL 验证。默认为 true。能够通过环境变量 GIT_SSL_NO_VERIFY 进行重写。

过失 4

> git缓存视频 push
# Enumerating objecthttp 404s: 76, done.
# Counting objects: 100% (76/76), donGite.
# Delta compression using up to 4 threads
# Compressgithub永久回家地址ing objGitHubects: 100% (59/59), done.
# Writing objects: 100% (60/60), 808.06 MiB | 10.78 MiB/s, done.
# Total 60 (delta 32), reused 0 (delta 0), pacgiti轮胎k-reused 0
# ergithub直播渠道永久回家ror: RPC failed; curl 18 transfer closhttp 302ed with outstanding read data remaining
# send-pack: unexpected disconnect while reading sideband packet
# fatal: the remote en缓存视频d hung up unexpectedly
#github打不开 Everything up-to-date

【解决办法】

  • 这种状况有可能是缓存过小引起的,我们能够查验增大缓存(缓存巨细依据实github中文官网网页践状况设置)
git config --global http.postBuffer 1048576000

# 单位https协议为 Byte,如 1048576000B 便是 1G

httgithub是干什么的p.postBuffergiti是什么牌子 实践上做了什么?Git 官网上有一段相关的阐明:

Maximum size in bytes of the buffer used by smagithub中文官网网页rt HTTP transports when P缓存视频合并OSTing data to the remogithub中文社区te system. F缓存视频变成本地视频or requests larger than this buffer size, HTTP/1giti是什么牌子.1 and Transfer-Encoding: chunked ihttp://www.baidu.coms used to avoid creatgiti是什么牌子ing a massive pack file locally. Default is 1 MiB, which is sufficient for most requests.

运用 smart HTTP 协议向长途 post 数据缓存视频合并app下载时,缓存区的最大github是干什么的巨细,单位为 byte。对大于这个缓存巨细的央求,会运用 HTTP/1.1 和 Transfer-Encoding: chunked 防止在缓存视频变成本地视频本地创建一个巨大的打包文件。默认为 1 MiB,关于大多数央求而github敞开私库言已经满足。

Notehttpwatch thttps和http的差异hat raising this limit is only effective for disabling chunked transfer encoding and therefore should be used only whehttps和http的差异re the remothttp代理e server or a proxy onlyGit sGitupports HTTP/1.0 or is noncompgithub敞开私库lgithub打不开iangithub永久回家地址t with the HTTP standard. Raising this is not, in general, an effective solution for most push problems, but can increase memory consumption significantly since the entire buffer is allocated even for small pushes缓存视频合并app下载.

留意,前进这个束缚只对禁用分块传输的git教程编码有用,因此只应在长途服务或代理只支撑 HTThttps协议P/1.0 或不符合 HTTP 规范的状况https和http的差异下运用。一般来说,前进这个束缚对大多数推送问题不是一个有用的解决方案,但会大大添加内存耗费,因为即便关于小规模的推送也会分配整个缓冲区。

  • 这种状况也可能是网络不坚Git定导致的,咱http://192.168.1.1登录们能够查验吊销相关的网络束缚
git config --global http.lowSpeedLimit 0
git config --global http.lowSpeedTime 999999

http.lowSpeedLimithttp.lowSpeedTime 实践上做了什么?官网上有一段相关的阐明:

If the缓存视频怎样转入本地视频 HTTP transfer speed is less than http.lowSphttpclienteedLimit for longehttps协议r than httgithub敞开私库p.lowSpeedTime seconds, thGitHube transfer is aborted. Can be overridden by the GIT_HTTP_LOW_SPEED_LIMIT and GIT_HTTP_LOW_SPEED_TIME envirHTTPonment variables.

若 HTTP 传输速度小于 http.lowSpeedLimit 或传输时间大于 http.lowSpeedTime,那么该传输就会连续。能够通过环境变量 GIT_HTTP_LOW_SPEED_LIMITGIT_HTTP缓存视频_LOW_SPhttp 302EED_TIME 进行重写。

  • 假设传输的gitlab文件真实太大,能够试试增大紧缩率(紧缩率巨细依据实践状况设置)
git config --global core.compressiohttps和http的差异n 3

core.compression 实践上做了什么?官网上有一段相关的阐明:

An integer -1…9, indicating a default compression level. -1 is the zlib default. 0 means no compHTTPSression, and 1…9 are various speed/size tradeoffs, 9 being slowest. If set, this provides a default to othhttps和http的差异er compreshttps认证sion variables, such as core.looseCompression and pack.compression.

用一个整数 -1 … 9 标明紧缩级别。-1 标明运用 zgithub敞开私库lib 默认值。0 意味着不紧缩,1 … 9 是紧缩速度/紧缩巨细的权衡,9 紧缩速度最github直播渠道永久回家慢/紧缩巨细最小。假设这个值被设置,那么将会给其它紧缩相关的变量github永久回家地址供应一个默认值,例如 core.looseCompresgithub永久回家地址sion 和 pack.compression。

  • 假设有多次提交一同推送,能够试试分多次推送【重要http代理
git push <长途http协议仓库称谓> <comm缓存文件在哪里it id>:<长途分支称谓>

# 这个指令会推送指定 <commit id> 前所有未推送的 commit