Does the .gitignore file belong in the .git folder structure somewhere or in the main source files?
Git Ignoring Files and Folders Checking if a file is ignored From Git 1.7. 6 onwards you can also use git status --ignored in order to see ignored files. You can find more info on this in the official documentation or in Finding files ignored by . gitignore.
If you want the ignored files to be tracked as part of the repo, and shared by other people who check it out, then the . gitignore file(s) must be tracked (checked in and versioned) like any other file. If you don't want the list of ignored files to be checked in and versioned then add filenames to .
gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.
Put .gitignore in the working directory. It doesn't work if you put it in the .git (repository) directory.
$ ls -1d .git*
.git
.gitignore
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.
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.
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