Why I can't delete file in git?? When I write $ git rm Food101.mlmodel
git says - fatal: pathspec 'Food101.mlmodel' did not match any files
. But when I write git push
git say, that Food101.mlmodel is very large. How to fix it?

- 41
- 10
-
That means file not exist in repo to delete. Try increasing you buffer – Praveen Govind Jan 04 '19 at 10:32
-
Can you see your file in the output from `git ls-files`? – Jerzy Pawlikowski Jan 04 '19 at 10:32
-
Try this to push large files https://stackoverflow.com/q/44780221/1544977 – Praveen Govind Jan 04 '19 at 10:35
-
@JerzyPawlikowski, I can't – Valter Jan 04 '19 at 10:37
-
It seems that the file is not in the repo so you cannot delete it. However `git push` sends commits rather than files. Is it possible that you are pushing multiple commits and in one of the commits you added large file and in the other commit you removed it? – Jerzy Pawlikowski Jan 04 '19 at 10:44
-
@JerzyPawlikowski, yes – Valter Jan 04 '19 at 10:49
-
Then you can squash those commits using interactive rebase: `git rebase -i` – Jerzy Pawlikowski Jan 04 '19 at 10:53
-
@JerzyPawlikowski, it doesn't work – Valter Jan 04 '19 at 10:59
-
It means that you have your file still in one or more commits. – Jerzy Pawlikowski Jan 04 '19 at 12:11
-
Possible duplicate of [How to remove/delete a large file from commit history in Git repository?](https://stackoverflow.com/questions/2100907/how-to-remove-delete-a-large-file-from-commit-history-in-git-repository) – phd Jan 04 '19 at 19:48
-
https://stackoverflow.com/search?q=%5Bgit%5D+remove+large+file+history – phd Jan 04 '19 at 19:48
1 Answers
On first glance it seems you have misinterpreted what git rm
does.
Food101.mlmodel
is contained in atleast one commit. That is, you have already called git add Food101.mlmodel
and git commit
. The error / warning you are getting is when you then git push
.
git rm
will never remove a file from a previous commit. It will only remove the file ready to commit a version of code that no-longer contains it. That doesn't sound like what you want.
It sounds like you need to re-write your commit history so that it doesn't contain Food101.mlmodel
at all. To do this, I suggest you look for answers on how to "rebase" your commits to remove a file. Or if it's only contained in your last commit or two you might prefer to simply use git reset HEAD~
to step back a commit, and re-commit your changes minus the large file.

- 13,581
- 5
- 53
- 85