Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where does the .gitignore file belong?

Tags:

git

gitignore

Does the .gitignore file belong in the .git folder structure somewhere or in the main source files?

like image 437
mishaF Avatar asked Apr 18 '11 03:04

mishaF


People also ask

How do I show a .gitignore file?

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.

Is Gitignore part of repo?

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 .

What is the Gitignore file?

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.


3 Answers

Put .gitignore in the working directory. It doesn't work if you put it in the .git (repository) directory.

$ ls -1d .git*
.git
.gitignore
like image 139
jmulho Avatar answered Oct 10 '22 20:10

jmulho


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.

like image 83
Alan Haggai Alavi Avatar answered Oct 10 '22 20:10

Alan Haggai Alavi


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.

like image 59
philipk Avatar answered Oct 10 '22 21:10

philipk