golang 下载依赖包时调用 git fetch出现以下404错误:
go: domain/path@version: reading xxx at revision vxxx: git fetch -f domain/path refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /root/go/pkg/mod/cache/vcs/010cec9e1885f646fe4edf45a7b9e645841cdd7ec0f3b5816641e433ca1e5ea4: exit status 128:
error: RPC failed; result=22, HTTP code = 404
fatal: The remote end hung up unexpectedly
手动尝试 git fetch -f domain/path 出现同样错误:
但是,同一个包在其他机器上可以成功下载。
先说解决方式:升级git,我是升到2.*,理论上越高越好吧。
再说解决过程:
由于A机器可以下载,B机器不行,所以在A机器手动执行 git fetch -f domain/path,发现有这么一行
warning: redirecting to https://domain/xxx.git/
也就是说,fetch domain/path 时,被重定向到 domain/path.git,实际访问的是后者。
接着,在B机器手动执行 git fetch -f domain/path.git,没问题,可以成功。
但是,同样的源,为什么B机器不能自己 redirect 呢?
所以,对比两台机器的 git 配置,发现配置相同,但 git 版本不同
A机器:2.20.1
B机器:1.8.3.1
升级B机器 git ,问题解决~