Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comments in .gitignore?

Can you write comments in a .gitignore file?

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

like image 829
James Raitsev Avatar asked Jan 14 '12 22:01

James Raitsev


People also ask

How do I comment in Gitignore?

We can also put comments in the gitignore file by just putting a # sign in front of any text that we want to be a comment in the gitignore file, maybe we want to provide the reason why we ignored something and any blank lines are simply going to be skipped.

What is /* in Gitignore?

The ignore statement * will ignore everything by default, including the root directory and all of its contents. So at this point, all files and folders in the root directory are ignored. The !* . php command will re-include all the *.

How do I use .gitignore file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a . gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

How do I use wildcards in Gitignore?

. gitignore is a plain text file in which each line contains a pattern for files or directories to ignore. It uses globbing patterns to match filenames with wildcard characters. If you have files or directories containing a wildcard pattern, you can use a single backslash ( \ ) to escape the character.


1 Answers

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 
like image 118
TimWolla Avatar answered Sep 16 '22 15:09

TimWolla