git一不小心上传了大文件,怎么破?

1、重写commit,删除大文件

git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch CPT_0707_ao/temp_past/temp2/deltap.csv" --prune-empty --tag-name-filter cat -- --all

2、如果报错了咋办?

报错:Cannot rewrite branches: Your index contains uncommitted changes.

解决:git stash

3、如果没有报错,就一直等待清理完成,推送即可:

git push origin master --force

如果报了第2步的错,就需要解决后重新执行:git filter-branch --force --index-filter "git rm -rf --cached --ignore-unmatch CPT_0707_ao/temp_past/temp2/deltap.csv" --prune-empty --tag-name-filter cat -- --all,等待修复完成后git push

4、清理和回收空间

rm -rf .git/refs/original/

git reflog expire --expire=now --all

git gc --prune=now

 

详见https://www.bbsmax.com/A/amd0l6kqdg/

 

posted @ 2021-03-26 13:49  狂飙的老蜗牛  阅读(846)  评论(0编辑  收藏  举报