Git : How to remove a big file wrongly committed

This article saved my ass. How to remove a big file wrongly committed.

TL;DR

If you get this


remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git-lfs.github.com.
remote: error: Trace: 7d51855d4f834a90c5a5a526e93d2668
remote: error: See http://git.io/iEPt8g for more information.
remote: error: File coverage/sensitivity/simulated.bed is 102.00 MB; this exceeds GitHub's file size limit of 100.00 MB

And want to remove it from your branch commits, do this.


git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git push

As with most things with Git it can royally wreck your repo so use it with caution.
Git filter-branch doc.

1 thought on “Git : How to remove a big file wrongly committed”

  1. git filter-branch –tree-filter “rm -rf CSVs/filesTooBig.csv” HEAD
    WARNING: git-filter-branch has a glut of gotchas generating mangled history
    rewrites. Hit Ctrl-C before proceeding to abort, then use an
    alternative filtering tool such as ‘git filter-repo’
    (https://github.com/newren/git-filter-repo/) instead. See the
    filter-branch manual page for more details; to squelch this warning,
    set FILTER_BRANCH_SQUELCH_WARNING=1.
    Proceeding with filter-branch…

    Rewrite a7238222b6f42008347b2c0e3b374b8a1e5e0775 (6/6) (51 seconds passed, remaining 0 predicted)
    Ref ‘refs/heads/main’ was rewritten

    git push
    To https://github.com/phdml/repo-site-ca-challenge.git
    ! [rejected] main -> main (non-fast-forward)
    error: failed to push some refs to ‘https://github.com/phdml/repo-site-ca-challenge.git’
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: ‘git pull …’) before pushing again.
    hint: See the ‘Note about fast-forwards’ in ‘git push –help’ for details.

    Reply

Leave a Comment