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/

本博客纯粹是学习过程中的笔记,部分来自转载或摘抄,如有侵权,请联系删除 email:18017870857@163.com
原文地址:https://www.cnblogs.com/yanzhuping/p/14581986.html