hook declined to update refs/heads/dev

提交一个项目,push的时候,报错:

warning: Large files detected.
remote: error: File TaodangpuAuction/TaodangpuAuction/AuctionClasses/Discover/TXLiteAVSDK/TXLiteAVSDK_UGC.framework/TXLiteAVSDK_UGC is 120.68 MB; this exceeds file size limit of 100.0 MB
remote: error: hook declined to update refs/heads/dev
To https://gitee.com/doubleyao1116/JianHuo.git
 ! [remote rejected]   dev -> dev (hook declined)
error: failed to push some refs to 'https://gitee.com/doubleyao1116/JianHuo.git'
bogon:天天鉴定dev mac$ 

原因是有一个文件超过了git服务器对文件大小的限制。

删掉本地文件,再推,还是报错。加忽略文件,再推也是报错。回滚,再推,还是同样的错误。

最后发现是这个大文件已经保存到了log中,因此无论怎么删改,这个文件没有从log中剔除就总会报出相同的错误。所以要在日志中把这个文件删除即可。

命令如下:

git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch xxx.rar" -- --all

上面的xxx.rar就是上面上传的大文件

git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch TaodangpuAuction/TaodangpuAuction/AuctionClasses/Discover/TXLiteAVSDK/TXLiteAVSDK_UGC.framework/TXLiteAVSDK_UGC" -- --all

上面的过程会很长,不要担心,看见扫描的文件一个一个的变少,那就是离成功更近了。

最后再git push就好了

原文地址:https://www.cnblogs.com/jingxin1992/p/11024095.html