git warning: redirecting to https://xxx.xxx.xxxx/xxx/xxx.git/

warning: redirecting to https://xxx.xxx.xxxx/xxx/xxx.git/
Counting objects: 429, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (161/161), done.
error: RPC failed; HTTP 413 curl 22 The requested URL returned error: 413 Request Entity Too Large
fatal: The remote end hung up unexpectedly
Writing objects: 100% (429/429), 153.87 MiB | 67.45 MiB/s, done.
Total 429 (delta 260), reused 351 (delta 225)
fatal: The remote end hung up unexpectedly
Everything up-to-date

网上参考了各种文档,如下。都没有解决

https://www.cnblogs.com/lihaiping/p/6021813.html

https://blog.****.net/xiao907182878/article/details/81383272

https://segmentfault.com/a/1190000017550420

https://blog.****.net/shenyo/article/details/84103429

https://www.jianshu.com/p/4f2ccb48da77

 

后来发现gitlab工程项目非常大。有500多M。用linux命令进入工程项目目录,用du . 命令查看项目目录

git warning: redirecting to https://xxx.xxx.xxxx/xxx/xxx.git/

 

可以看到./.git/objects/pack和./.git/objects目录非常大。

当前项目目录,执行git verify-pack -v .git/objects/pack/pack-*.idx | sort -k 3 -g | tail -5 命令,查看里面具体的大文件如下:

git warning: redirecting to https://xxx.xxx.xxxx/xxx/xxx.git/

第一行的字母其实相当于文件的id,用以下命令可以找出id对应的文件名:

git rev-list --objects --all | grep 8e916e110236e0d12010c18e3bca2295a7922d89

git warning: redirecting to https://xxx.xxx.xxxx/xxx/xxx.git/

执行如下命令:

git filter-branch --force --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch XXX.framework' --tag-name-filter cat -- --all

git push --force --all

OK.至此问题解决,可以用命令查看git项目大小,已经给只有几M了