Can you have additional .gitignore per directory within a single repo?

GitVersion ControlRepositoryGitignore

Git Problem Overview


Can you create a .gitignore file in a directory that only applies to files (and directories) within that directory?

Git Solutions


Solution 1 - Git

Yes, you can. Try it, it works fine. Put a .gitignore in the root of your repo, and put another .gitignore with additional things to ignore in a subdirectory.

Solution 2 - Git

Solution 3 - Git

You can just specify files to ignore in a format such as

Xyz/*.abc

in the .gitignore in the root directory, potentially removing the need for separate ignore files.

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
QuestionB SevenView Question on Stackoverflow
Solution 1 - GitMike MoreartyView Answer on Stackoverflow
Solution 2 - GitTats_innitView Answer on Stackoverflow
Solution 3 - GitlearnvstView Answer on Stackoverflow