Reputation: 2926
I was trying to create an alias with # in it and found I can't.
Alias:
ignored = !sh -c -e -v "cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v `#` | grep ."
I already found a MUCH better way to do this (find -type f | git check-ignore --stdin
- gives files ignored in the repo, not just patterns) but am still curious how could I avoid git thinking "oh, it's a # the rest must be a comment" and ignoring it. I tried various quoting (backtics, double and single quotes, slash) but nothing worked. In shell, the command works of course.
So, the question: how to use a hash in a git config file in a shell (sh -c
or a function) alias so that it's actually NOT treated as a comment?
Upvotes: 1
Views: 124
Reputation: 94539
The following variant works for me:
ignored = !"cat .gitignore .git/info/exclude $HOME/.config/git/ignore | grep -v '#' | grep ."
I.e., no 3rd shell, and single quotes around #
.
Upvotes: 1