0

I'm trying to run the git rm command but it returns with:

No such file or directory

I tried executing the following commands from the project root directory but none worked:

git rm --cached Videos/video-1.mp4
git rm --cached /Videos/video-1.mp4
git rm --cached ./Videos/video-1.mp4
git rm --cached ~/Videos/video-1.mp4

The file does in fact exist in this folder. I'm using a MacBook.

Johann
  • 27,536
  • 39
  • 165
  • 279
  • 3
    Your attempts suggest you have an incomplete grasp of how the file system works, and so it's hard to assess your statement that the file actually exists. Please [edit] to provide details about what exactly exists and where exactly. Where is the `.git` folder relative to where you are running these commands? Perhaps see also [Difference between `./` and `~/`](https://stackoverflow.com/questions/31435921/difference-between-and/55342466) – tripleee Oct 04 '22 at 07:10
  • 1
    perhaps a FS casing problem sticking out its head? – eftshift0 Oct 04 '22 at 07:53
  • If `git rm --cached` cannot find some file, it says `fatal: pathspec '...' did not match any files`, so `git rm` is not running in the first place. – torek Oct 04 '22 at 15:49

1 Answers1

1

The file does in fact exist in this folder

Yes, but check if Videos itself is not the root folder of a submodule repository (check for a .gitmodules in your project root directory).
Or check the output of git ls-tree master Videos

If you see 160000, that means Videos is a nested Git repository, and you cannot git rm a file from the parent repository.

Note that generally $HOME (~) is rarely a Git repository, and large binary files like video files are rarely added to a source control system like Git.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • No submodule repositories exist. It's just one repo. – Johann Oct 04 '22 at 07:17
  • @Johann Syill, what does `git ls-tree master Videos` return? (when executed in its parent folder) – VonC Oct 04 '22 at 07:18
  • "No such file or directory" – Johann Oct 04 '22 at 07:31
  • What does `git version` return? What does `which git` return? What does `file $(which git)` return? (My suspicion is that there is something wrong with your `git` command in general, not with `git rm` in particular). – j6t Oct 04 '22 at 08:08
  • @Johann Did you see J6t's comment? – VonC Oct 04 '22 at 08:34
  • @Johann : does `git ls-tree master videos` (with lowercase `v`) also say "No such file or directory" ? – LeGEC Oct 04 '22 at 09:01