tags:

views:

40

answers:

1

hello

I want to ignore all of .gitignore rules in subdirectory except .gitignore rules in root.

for example) I have already .gitignore file in a directory structure /a.

And also have .gitignore file in /a/b. Assume /a have a.txt b.txt files.

/a/b has .config file. .gitignore defines .config in /a/b.

.config file will be ignored by .gitignore in /a/b.

But I really want to track .config file by ignoring rules of .gitignore in subdirectory.

Is it possible?

Thanks in advance

A: 

Your question isn't too clear, but if there are some subdirectories where you want different gitignore rules, you can just create a new .gitignore in that directory.

Say you have:

project/.gitignore
project/stuff/.gitignore

The .gitignore in stuff/ will override the .gitignore in the root directory.

git help gitignore or man gitignore has quite a bit more information about what's possible.

signine
I think the OP is asking if you have a directory structure `/a/b/c` and you update `.gitignore` in `/a/b`, is it possible in `/a/b/c` to ignore the rules in `/a/b` and instead only use rules from `/a`.
Michael Mior
Yeah, if that was the question, it is possible to negate rules in a .gitignore further down the chain. `"An optional prefix ! which negates the pattern; any matching file excluded by a previous pattern will become included again."`
signine
for example) I have already `.gitignore` file in a directory structure `/a`. And also have `.gitignore` file in `/a/b`. Assume `/a` have `a.txt` `b.txt` files. `/a/b` has `.config` file. `.gitignore` defines `.config` in `/a/b`. `.config` file will be ignored by `.gitignore` in `/a/b`. But I really want to track `.config` file by ignoring rules of `.gitignore` in subdirectory.
rafael