Comments in .gitignore?

GitCommentsGitignore

Git Problem Overview


Can you write comments in a .gitignore file?

If so, should the line be preceded with a # or some other indicator?

Git Solutions


Solution 1 - Git

Yes, you may put comments in there. They however must start at the beginning of a line.

cf. http://git-scm.com/book/en/Git-Basics-Recording-Changes-to-the-Repository#Ignoring-Files

> The rules for the patterns you can put in the .gitignore file are as follows:

  • Blank lines or lines starting with # are ignored.
    […]

The comment character is #, example:

# no .a files
*.a

Solution 2 - Git

Do git help gitignore

You will get the help page with following line:

A line starting with # serves as a comment.

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
QuestionJames RaitsevView Question on Stackoverflow
Solution 1 - GitTimWollaView Answer on Stackoverflow
Solution 2 - GitmanojldsView Answer on Stackoverflow