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
gitignore file is usually placed in the repository's root directory. However, you can create multiple . gitignore files in different subdirectories in your repository.
gitignore , nor in the global . gitignore , can be ignored using explicit repository excludes in your_project_directory/. git/info/exclude . This file will not be shared with other developers, and is specific for that single repository.
A . gitignore file is a plain text file where each line contains a pattern for files/directories to ignore. Generally, this is placed in the root folder of the repository, and that's what I recommend. However, you can put it in any folder in the repository and you can also have multiple .
The easiest and most common way to ignore files is to use a gitignore file. Simply create a file named . gitignore in the repository's root directory. Then, add names and patterns for any files and directories that should not be added to the repository.
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.
Lets say you want to include node_modules
in your repository, but some module down the line has .gitignore
of its own. You can negate the rules by adding the following to your root .gitignore
file:
# Make sure to include everything in node_modules. !node_modules/**
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With