我不小心将大文件夹提交/推送到 github,并且无法进一步推送。当尝试提交和推送时,我收到以下消息。 “批量响应:此存储库超出其数据配额。负责 LFS 带宽的帐户应购买更多数据包以恢复访问。”我想删除 .next folder。我不想购买更多存储空间。我正在使用 git bash 和 windows 10。
到目前为止我已经尝试过的尝试。
添加到
.gitignore
文件并推送。
git filter-branch --tree-filter "rm -rf .next" --prune-empty HEAD git for-each-ref --format="%(refname)" refs/original/ | git for-each-ref --format="%(refname)" refs/original/ | xargs -n 1 git update-ref -d 回声 .next/ >> .gitignore git add .gitignore git commit -m '从 git 历史记录中删除 .next' git GC git push origin master --force
git rm -r --缓存我的文件夹
git filter-branch -f --index-filter "git rm -rf --cached --ignore-unmatch FOLDERNAME" -- --all
replace FOLDERNAME with the file or folder you wish to remove from the given git repository.
Once this is done run the following commands to clean up the local repository:
rm -rf .git/refs/original/
git reflog expire --expire=now --all
git gc --prune=now
git gc --aggressive --prune=now
Now push all the changes to the remote repository:
git push --all --force
这将清理远程存储库。*我的存储库链接如下。
https://github.com/Rinzler8806/crowdCoin
感谢您的帮助!
filter-branch
。有一个关于它的线程here提供了更多信息,但本质上您可以使用以下命令:
git-filter-repo --path <dir> --invert-paths
对于任何目录。之后,您应该能够将文件添加到您的
.gitignore
或使用 git 的 LFS(如果您仍想尝试提交/推送它)。