Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
in DevOps and Agile by (19.4k points)

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

1 Answer

+1 vote
by (27.5k points)

You need to put .gitignore in the working directory. It won't work if you put it in the .git (repository) directory. In other words, you can place the .gitignore file anywhere in the working directory, i.e in any folder where your code prevails. But the best practice would be to place the .gitignore file in the root directory. This means that one .gitignore file for one entire repo. This makes managing the ignored files more effectively. 

$ ls -1d .git*

$ .git

$ .gitignore

Browse Categories