Reputation: 4578
I am trying to push my local branch to my origin branch with git push origin <branchname>
.
I get a:
remote: error: File app/assets/images/title00.mp4 is 297.77 MB;
error which complains I surpass the file size allowed by GitHub.
The file it is complaining about is no longer in my version control as I deleted it for that exact reason of it being too big.
So when I try to follow the Git Documentations suggestion of doing
git rm <path-to-large-file>
I get the following error:
fatal: pathspec 'app/assets/images/title00.mp4' did not match any files
Any idea how I should proceed?
Upvotes: 2
Views: 71
Reputation: 16512
From the Rewriting History Git docs:
Removing a File from Every Commit
This occurs fairly commonly. Someone accidentally commits a huge binary file with a thoughtless
git add .
, and you want to remove it everywhere. Perhaps you accidentally committed a file that contained a password, and you want to make your project open source.filter-branch
is the tool you probably want to use to scrub your entire history. To remove a file namedpasswords.txt
from your entire history, you can use the--tree-filter
option tofilter-branch
:
$ git filter-branch --tree-filter 'rm -f passwords.txt' HEAD
Rewrite 6b9b3cf04e7c5686a9cb838c3f36a8cb6a0fc2bd (21/21)
Ref 'refs/heads/master' was rewritten
In your scenario, you will probably want to do:
git filter-branch --tree-filter 'rm -f app/assets/images/title00.mp4' HEAD
Upvotes: 2
Reputation: 1277
You can clean files from your repo history with the great BFG repo cleaner. Basically, you can run the following steps
First.
Install bfg cleaner. In MacOSX, with brew install bfg
.
Second, clear your file from your history.
git clone --mirror [email protected]:your_github_user/your_github_repo.git
bfg --delete-files title00.mp4 your_github_repo.git
cd your_github_repo.git
git reflog expire --expire=now --all && git gc --prune=now --aggressive
git push
Then you have to clear your non mirror repor (your development folder) and clone it again from github to avoid repush the big file.
git clone [email protected]:your_github_user/your_github_repo.git
Obviously, more information in BFG website.
Upvotes: 0