2

I am in a bit of a pickle with my remote master branch. I am working on a project with a guy who is new to version control systems and he made several commits with an empty .gitignore file. This resulted in many different binaries being pushed into /bin/ and /obj/ directories. I have successfully removed all of the files in the dev branch by using the git rm -rf --cached <file/directory> command, but git does not see the directories in the index of master even though they exist in the remote repository and my local repository.

Every time I try to git rm -rf --cached <file/directory/ on the master branch, git tells me this fatal: pathspec 'EscapeTheHordeDAL/bin/' did not match any files. How can I resolve this and remove these directories from the repository when git doesn't even see them?

msdedwards
  • 509
  • 4
  • 20
  • Have you looked at this [answer](http://stackoverflow.com/a/15931542/3799138)? – msdedwards Feb 26 '16 at 23:36
  • Possible duplicate of [unable to remove file that really exists - fatal: pathspec ... did not match any files](http://stackoverflow.com/questions/15931238/unable-to-remove-file-that-really-exists-fatal-pathspec-did-not-match-any) – TheGeorgeous Feb 27 '16 at 04:14

1 Answers1

2

Git is correct that the bin/ directory does not match any files that git sees.

This is because, as you mentioned, you have a .gitignore to filter out these binary files, and a .gitignore is not only a commit ignore, it is an ignore for everything that git does (unless told otherwise, like below).

To get rid of the files which are in your .gitignore you need to use git clean -xf orgit clean -xdf (if directories are ignored). Those are destructive commands, so you'll probably want to run it with -n first, or in interactive mode with git clean -xdi.

git clean works with untracked files, and these are clearly untracked now, or else git rm should have worked. The -x tells git to not use standard ignore rules (read from .gitignore's).

Bujiraso
  • 289
  • 2
  • 13