remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git

这篇博客指导如何处理Git中检测到的大文件,提供了两种解决方案:BFG Repo-Cleaner和命令行工具。内容包括从最近的未推送提交中移除文件的步骤,警告读者在操作前备份重要文件,以及如何在已提交历史中删除文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这部分适合一开始没有提交过的文件,如果一开始就已经commit过了,甚至开了很多分支的话,这部分不适合,跳到第二部分

Warning: These procedures will permanently remove files from the repository on your computer and GitHub. If the file is important, make a local backup copy in a directory outside of the repository.

If you added a file in an earlier commit, you need to remove it from your repository history. You can remove files from your repository history using either the BFG Repo-Cleaner or the git filter-branch command. For more information, see "Removing sensitive data from a repository."

Removing a file added in the most recent unpushed commit

If the file was added with your most recent commit, and you have not pushed to GitHub, you can delete the file and amend the commit:

  1. Open TerminalTerminalGit Bashthe terminal.

  2. Change the current working directory to your local repository.

  3. To remove the file, enter git rm --cached:

    $ git rm --cached giant_file
    # Stage our giant file for removal, but leave it on disk
  4. Commit this change using --amend -CHEAD:

    $ git commit --amend -CHEAD
    # Amend the previous commit with your change
    # Simply making a new commit won't work, as you need
    # to remove the file from the unpushed history as well
  5. Push your commits to GitHub:

    $ git push
    # Push our rewritten, smaller commit

part2

https://help.github.com/en/articles/removing-sensitive-data-from-a-repository

$ git filter-branch --force --index-filter  'git rm --cached --ignore-unmatch PATH-TO-YOUR-FILE-WITH-SENSITIVE-DATA'  --prune-empty --tag-name-filter cat -- --all

$ echo "YOUR-FILE-WITH-SENSITIVE-DATA" >> .gitignore
$ git add .gitignore
$ git commit -m "Add YOUR-FILE-WITH-SENSITIVE-DATA to .gitignore"

然后就可以愉快的提交了。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值