Exceptions in a .gitignore file

suggest change

If you ignore files by using a pattern but have exceptions, prefix an exclamation mark(!) to the exception. For example:


The above example instructs Git to ignore all files with the .txt extension except for files named important.txt.

If the file is in an ignored folder, you can NOT re-include it so easily:


In this example all .txt files in the folder would remain ignored.

The right way is re-include the folder itself on a separate line, then ignore all files in folder by \*, finally re-include the *.txt in folder, as the following:


Note: For file names beginning with an exclamation mark, add two exclamation marks or escape with the \\ character:


Feedback about page:

Optional: your email if you want me to get back to you:

Table Of Contents