Where does the .gitignore file belong?
As the other answers stated, you can place .gitignore
within any directory in a Git repository. However, if you need to have a private version of .gitignore
, you can add the rules to .git/info/exclude
file.
Put .gitignore in the working directory. It doesn't work if you put it in the .git (repository) directory.
$ ls -1d .git*
.git
.gitignore
When in doubt just place it in the root of your repository. See https://help.github.com/articles/ignoring-files/ for more information.
You can place .gitignore in any directory in git.
It's commonly used as a placeholder file in folders, since folders aren't usually tracked by git.