Skip to content

Commit 866f5f8

Browse files
pcloudsgitster
authored andcommitted
gitignore.txt: suggestions how to get literal # or ! at the beginning
We support backslash escape, but we hide the details behind the phrase "a shell glob suitable for consumption by fnmatch(3)". So it may not be obvious how one can get literal # or ! at the beginning of pattern. Add a few lines on how to work around the magic characters. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 889d358 commit 866f5f8

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Documentation/gitignore.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,15 @@ PATTERN FORMAT
6868
for readability.
6969

7070
- A line starting with # serves as a comment.
71+
Put a backslash ("`\`") in front of the first hash for patterns
72+
that begin with a hash.
7173

72-
- An optional prefix '!' which negates the pattern; any
74+
- An optional prefix "`!`" which negates the pattern; any
7375
matching file excluded by a previous pattern will become
7476
included again. If a negated pattern matches, this will
7577
override lower precedence patterns sources.
78+
Put a backslash ("`\`") in front of the first "`!`" for patterns
79+
that begin with a literal "`!`", for example, "`\!important!.txt`".
7680

7781
- If the pattern ends with a slash, it is removed for the
7882
purpose of the following description, but it would only find

0 commit comments

Comments
 (0)