我尝试将一个文件添加到我的存储库中,但超出了 github 限制。不幸的是我删除了它,但当我推送时它仍然尝试添加它。
rm dist/img/work.zip
fatal: pathspec 'dist/img/work.zip' did not match any files
如何将其从存储库中取出?
最佳答案
使用命令
git filter-branch --force --index-filter \ 'git rm -r --cached --ignore-unmatch dist/img/work.zip' \ --prune-empty --tag-name-filter cat -- --all
过滤器分支完成后,验证没有意外文件丢失。
现在添加 .gitignore 规则
echo dist/img/work.zip >> .gitignore git add .gitignore && git commit -m "ignore rule for files"
现在进行推送
git push -f origin branch
关于file - Github,文件太大已删除。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42143269/