Best Practice for Adding .gitignore to Repo

GitGitignore

Git Problem Overview


What is the best practice regarding the .gitignore file with Git; should it be excluded from the repository or included? If it's conditional, what are the conditions for each circumstance?

Git Solutions


Solution 1 - Git

They should almost always be included, as their purpose is to ignore "output" files (compiled binaries, log files) which are going to be generated by anybody working with a clone of your project. They're meant to be version-controlled and included with the repository.

You should not use .gitignore files within the repository to ignore files that only appear for you, such as editor-specific swap files. You should be placing those rules in a global .gitignore file so that they apply to all repositories, or in .git/info/excludes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionE-richView Question on Stackoverflow
Solution 1 - Gituser229044View Answer on Stackoverflow