Ignore pattern with trailing whitespace in .gitignore is void using git 1.8.1.5
- From
- Thor 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.