You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Git Push因历史提交含超大Zip触发文件大小限制报错,需保留有效修改

Got it, let's work through this problem step by step. The root of the issue is that Git pushes your entire commit history when you push your latest changes—so that problematic commit (f0ce53a) with the oversized zip is getting dragged along every time. We need to rewrite that commit to remove the zip file while keeping its valid changes, then update your remote repo safely.

Solution 1: Interactive Rebase (Best for Recent Commits)

This method lets you directly edit the problematic commit without rewriting too much of your history:

  1. Start an interactive rebase targeting the commit right before f0ce53a:

    git rebase -i f0ce53a^
    

    This will open a text editor listing all commits from f0ce53a onward.

  2. In the editor, change the word pick next to commit f0ce53a to edit, then save and close the editor. Git will now pause at the state of that commit.

  3. Remove the oversized zip file from the commit:

    # Use --cached if the file is already in .gitignore, omit it otherwise
    git rm --cached path/to/your/large/file.zip
    
  4. Amend the commit to save the change (keeping the original commit message):

    git commit --amend --no-edit
    
  5. Resume the rebase process:

    git rebase --continue
    

    If you hit any merge conflicts, resolve them, stage the resolved files with git add, then run git rebase --continue again.

  6. Push your rewritten history to the remote. Since we modified existing commits, we need a force push—but use the safer --force-with-lease option to avoid overwriting others' work:

    git push --force-with-lease origin your-branch-name
    

Solution 2: git filter-repo (Best for Bulk History Edits)

If you have multiple commits that might include the zip file, or if the rebase feels too tedious, use git filter-repo (the modern replacement for the outdated git filter-branch):

  1. First, back up your local repo—this rewrites history, so having a copy is critical:

    cp -r your-repository-folder your-repository-folder-backup
    
  2. Run the filter command to remove the zip file from all commits:

    git filter-repo --path path/to/your/large/file.zip --invert-paths
    
  3. Push the rewritten history to the remote with a safe force push:

    git push --force-with-lease origin your-branch-name
    

Important Notes

  • If you're collaborating with a team, warn your teammates that you've rewritten the branch history. They'll need to rebase their local copies or clone the repo fresh to avoid conflicts.
  • Add the zip file to your .gitignore to prevent accidentally committing it again:
    echo "path/to/your/large/file.zip" >> .gitignore
    git add .gitignore
    git commit -m "Add zip file to .gitignore"
    git push origin your-branch-name
    

内容的提问来源于stack exchange,提问作者Eironeia

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 06:28:28