Lajos Arpad Lajos Arpad - 3 months ago 15
Git Question

gitignore does not ignore folder

In the root of my project I have a

foo
folder. Inside the
foo
folder I have a
bar
folder. I would like to ignore all changes to all files inside my
bar
folder. I have this in my
gitignore
:

/foo/bar


The folder is checked: it exists and it has the files to be ignored.
gitignore
is
commit
ted. However, I have a file where I make a moification and is inside my
bar
folder. When I type

git status


inside my
git bash
I see the file which should have been ignored. What could be the reason and how can I successfully ignore all files inside my bar folder?

Note, that the files were previously ignored with the same line, but I had to temporarily remove that line to
commit
something on the server. After the
commit
, I put back the line into the
gitignore
. This was a while ago, but now I have observed that the files will be in
git status
. I would expect to be able to modify the ignored files without they appearing in the
git status
.

Answer

I'm guessing this folder has been checked into git before? Try running git rm --cached <folder> and check again.

EDIT: The code had a little bug in it. The solution was: git rm -r --cached <folder> However, this answer has led me to the solution, so I will accept it.

UPDATE: The -r is required.