Valter
Valter

Reputation: 29

Why I can't delete files in git?

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?

Upvotes: 0

Views: 1800

Answers (1)

Philip Couling
Philip Couling

Reputation: 14893

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.

Upvotes: 1

Related Questions