Can you have multiple .gitignore files in one repo?

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

+57
git version-control repository gitignore
Mar 16 2018-12-12T00:
source share
3 answers

Yes, you can. Try it, everything will be fine. Put a .gitignore at the root of your repo and add another .gitignore with extra things to ignore in the subdirectory.

+88
Mar 16 '12 at 7:22
source share

Related questions: Are a few `.gitignore` frowned? (July 2010)

Or, if you may have a different version of the .gitignore file for each branch: Using github to host public git repositories, ensuring that sensitive data files are left without a trace (February 2010)

Further, possibly related: How do I tell git to always choose my local version for conflicting merges in a specific file?

+5
Mar 16 '12 at 1:13
source share

You can simply specify files to ignore in a format like

 Xyz/*.abc 

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

+1
Mar 16 '12 at 1:27
source share



All Articles