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

Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5

From
TRThor Andreas Rognan <thor.rognan@gmail.com>
Date
Mar 9, 2013, 01:36 UTC
Message-ID
<CAMn8hCexsiizsjoXO-ebfpEtZcW7n0dY-jV0q+aLh8U+pbUo9A@mail.gmail.com>
In-Reply-To
<CAMn8hCd6_V2Kq_OUgBFAoOkqqmrTpN_ohcP3wM44qWvQB_8R5g@mail.gmail.com>
Hi guys,

Maybe I'm doing it wrong, or maybe it's the intended behaviour, but I find that a trailing whitespace after a pattern in .gitignore makes the pattern void with git 1.8.1.5.

It's a subtle error to make, although cleaning undesired commits from the git history can be educational and fun in itself.

How to reproduce:

$ > mkdir -p ~/tmp/git-ignore-test/ \ && cd ~/tmp/git-ignore-test/ \ && touch .gitignore .secret-passwords .secret-passwords.swp \ && echo ".*.sw? " > .gitignore \ && echo ".secret-passwords" >> .gitignore \ && git init && git status

Remove the white space after ``` .*.sw?``` in .gitignore to see the .swp file disappear:

$ > echo -e ".*.sw?\n.secret-passwords" > .gitignore > .gitignore \ && git status

You will of course have to temporarily disable your global .gitignore file if you handle vim swap files correctly there.

I am using git 1.8.1.5 installed with homebrew on os x 10.8.2.
Next: Junio C Hamano
Message 1 of 3 in “Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5”
  1. Thor Andreas RognanMar 9, 2013
  2. Junio C HamanoMar 9, 2013
  3. Junio C HamanoMar 9, 2013

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.