Reputation: 15010
I have a .gitignore file with the following contents.
*.o
*.exe
*Debug/*
*.vpb
*.vtg
*.vpwhistu
*.vpwhist
*.vtg
After working on a project (modifying a couple of files) in my working directory, If I do
git status
I get the following output
Workspace/playpen/boost/Debug/simple_ls.o
Why is this happening despite *Debug/*
being inside .gitignore
. Isn't that the whole point of .gitignore.
Upvotes: 0
Views: 337
Reputation: 522646
.gitignore
only works on files which are not already part of the remote repository. My guess is that simple_ls.o
was already being tracked when you added the rule to .gitignore
. If you want Git to ignore it, then you first have to remove it from the remote repository via:
git rm --cached Workspace/playpen/boost/Debug/simple_ls.o
After this, the .gitignore
pattern will prevent this file from being added to the repository.
Upvotes: 1
Reputation: 793037
Having a /
in the your pattern (other than as the last character of the pattern) anchors the pattern at the point of the directory hierarchy that contains the .gitignore
file itself.
This means that *Debug/*
will ignore anything in directories such as FooDebug
, BarDebug
and Debug
at the same level as .gitignore
, but not further down the hierarchy. To ignore any directories which have names ending in Debug
, simply use the pattern:
*Debug/
The trailing slash tells Git to only match against directories, but this pattern will match at any level of your directory tree.
Upvotes: 0
Reputation: 576
Did you modify your .gitignore ? Was this file already tracked ? because it is supposed to ignore .o files too.
for ignoring the debug folder your should modify your rules as :
**Debug/
Upvotes: 0