git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2] gitignore.txt: suggestions how to get literal # or ! at the beginning

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Oct 6, 2012, 13:51 UTC
Message-ID
<1349531484-5938-1-git-send-email-pclouds@gmail.com>
In-Reply-To
<20121006132127.GC11712@sigill.intra.peff.net>

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 <pclouds@gmail.com>
---
 On Sat, Oct 6, 2012 at 8:21 PM, Jeff King <peff@peff.net> wrote:
 > It works fine for me with asciidoc 8.6.7. <sigh>
 8.6.5 works. I don't care deeply as I read .txt anyway. Here it goes
 again with examples.
 Documentation/gitignore.txt | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/Documentation/gitignore.txt b/Documentation/gitignore.txt
index 96639e0..0bcf079 100644
--- a/Documentation/gitignore.txt
+++ b/Documentation/gitignore.txt
@@ -73,12 +73,16 @@ PATTERN FORMAT
  - A blank line matches no files, so it can serve as a separator
    for readability.
 
- - A line starting with # serves as a comment.
+ - A line starting with "`#`" serves as a comment.
+   Use "`\#`" instead for patterns that begin with "`#`",
+   for example, "`\#backup#.txt`".
 
- - An optional prefix '!' which negates the pattern; any
+ - An optional prefix "`!`" which negates the pattern; any
    matching file excluded by a previous pattern will become
    included again.  If a negated pattern matches, this will
    override lower precedence patterns sources.
+   Use "`\!`" instead for patterns that begin with "`!`",
+   for example, "`\!important!.txt`".
 
  - If the pattern ends with a slash, it is removed for the
    purpose of the following description, but it would only find
-- 
1.7.12.1.406.g6ab07c4
Previous: Jeff KingNext: Jeff King
Message 5 of 8 in “gitignore.txt: suggestions how to get literal # or ! at the beginning”
  1. gitignore.txt: suggestions how to get literal # or ! at the beginningNguyễn Thái Ngọc Duy, Oct 6, 2012
  2. Philip OakleyOct 6, 2012
  3. Nguyen Thai Ngoc DuyOct 6, 2012
  4. Jeff KingOct 6, 2012
  5. gitignore.txt: suggestions how to get literal # or ! at the beginningNguyễn Thái Ngọc Duy, Oct 6, 2012
  6. Jeff KingOct 6, 2012
  7. Junio C HamanoOct 6, 2012
  8. gitignore.txt: suggestions how to get literal # or ! at the beginningNguyễn Thái Ngọc Duy, Oct 7, 2012

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.