0

I accidentally put a large tif file at the top level of a project. Found out when I tried to upload to github with an error similar to this:

remote: error: File 30.trans.cp.tif is 490.38 MB; this exceeds GitHub's file size limit of 100.00 MB

Fair enough, so I deleted the file manually (using the Finder in macOS, committed changes (I can't say what I saw when I did the commit). I then tried to push again and got a similar error.

Then tried:

git rm 30.trans.cp.tif
fatal: pathspec '30.trans.cp.tif' did not match any files

Then I checked out a branch and made a chance or two and recommitted, merged back to master (hoping that things would fix themselves) and tried pushing again and still the same problem. I removed the file from the Trash, put it back at the top level, committed it, then git rm 30.trans.cp.tif, committed and pushed but git push still had the same problem.

I just tried adding 30.trans.cp.tif to .gitignore but that didn't help either.

How do I get Git to not see this non-existent file anymore?

Greg
  • 2,359
  • 5
  • 22
  • 35
  • You need to remove this large file from _every_ commit in your history, not just the top level working directory. Given that it just happened, an interactive rebase might be sufficient here. If not that, then look into using filter-branch. – Tim Biegeleisen Jan 04 '18 at 02:15
  • Rebasing is beyond my Git knowledge, but I quickly read to checkout a version, then `git rebase master` and I got `Current branch ... is up to date.` Although I could see nothing happened I tried to merge the branch back in and `Already up-to-date.` I'll look up filter-branch. Thank you – Greg Jan 04 '18 at 02:21
  • If you tell me how many commits back the large file goes, I can attempt an answer using rebase. – Tim Biegeleisen Jan 04 '18 at 02:21
  • Or you could link to one of the many duplicate questions for exactly this issue on stackoverflow... – larsks Jan 04 '18 at 02:23
  • E.g.: https://stackoverflow.com/a/2158271/147356 – larsks Jan 04 '18 at 02:23
  • @Tim Biegeleisen Thank you. It seems to go back a bit and I haven't found it yet. @larsks `git filter-branch --tree-filter 'rm -f 30.trans.cp.tif' HEAD` did the trick. I should try to understand what all of this meant. – Greg Jan 04 '18 at 02:58
  • @larsks It has never been clear to me what the exact boundary is for a duplicate or non duplicate. I guess the OP should have shown some effort trying to remove the file in order to merit an answer. – Tim Biegeleisen Jan 04 '18 at 03:00

0 Answers0