从 git 存储库/历史记录中删除文件夹

问题描述 投票:0回答:1

我不小心将大文件夹提交/推送到 github,并且无法进一步推送。当尝试提交和推送时,我收到以下消息。 “批量响应:此存储库超出其数据配额。负责 LFS 带宽的帐户应购买更多数据包以恢复访问。”我想删除 .next folder。我不想购买更多存储空间。我正在使用 git bash 和 windows 10。

到目前为止我已经尝试过的尝试。

  1. 添加到

    .gitignore
    文件并推送。

  2. 按照此处提供的示例和解决方案

    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

  3. 提供的解决方案

    这里

    git rm -r --缓存我的文件夹

  4. 提供的解决方案

    这里

*CD 到本地工作文件夹并运行以下命令:

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

感谢您的帮助!

github version-control git-bash large-files git-lfs
1个回答
0
投票
git 本身现在建议为此目的使用

git-filter-repo

 而不是 filter-branch
。有一个关于它的线程
here提供了更多信息,但本质上您可以使用以下命令:

git-filter-repo --path <dir> --invert-paths
对于任何目录。

之后,您应该能够将文件添加到您的

.gitignore

 或使用 git 的 LFS(如果您仍想尝试提交/推送它)。

© www.soinside.com 2019 - 2024. All rights reserved.