From: Florian Hassanen Date: Thu, 11 Dec 2014 23:16:32 GMT Subject: Re: [PATCH] git-check-ignore.txt: Clarify exit codes Message-ID: In-Reply-To: >> check-ignore disregards whether a path is matched by a >> positive or negative pattern. Thus for a file that is _not_ >> ignored, but is captured by negative pattern in .gitignore, >> the exit code is 0. The docs suggested otherwise. > > I am not sure that is the actual behaviour of the command. Given > this .gitignore file: > > $ cat .gitignore; echo END > !vendor.o > *.o > END > > which is designed to allow binary-only blob "vendor.o" supplied by > the vendor to be tracked, but to ignore all the other usual build > artifacts, you see this: > > $ for o in a.o vendor.o; do git check-ignore $o >/dev/null; echo $?; done > 0 > 1 > > Puzzled... Maybe your global ignore file gets in the way? on both of my machines (cygwin + git 2.1.1, linux + git @master) I have: $ cat > .gitignore << EOF !vendor.o *.o EOF for o in a.o vendor.o; do git check-ignore $o >/dev/null; echo $?; done 0 0 which corresponds to how I understand the command so far :) is one of a.o and vendor.o already in your index? there is a --no-index as well (which enables yet another different behavior)