I'm trying to check files that are ignored by git, and I found 2 commands show same result.
which are
git check-ignore *git ls-files --others --ignored --exclude-standard
It seems different approach, but would it show same result in any condition?
I'm trying to check files that are ignored by git, and I found 2 commands show same result.
which are
git check-ignore *
git ls-files --others --ignored --exclude-standard
It seems different approach, but would it show same result in any condition?
Although not specifically documented, the difference is that git check-ignore <pathname> doesn't recurse into subdirectories1, while git ls-files --others does.
Let's say that your working directory looks like this:
.
|-- ignored-file
|-- bin
| |-- another-ignored-file
While being at the root of the working directory, if you run:
git check-ignore *
You'll get just ignored-file. If you run:
git ls-files --others --ignored --exclude-standard
You'll get:
ignored-filed
bin/another-ignored-file
Now, if you were to run both commands in the bin directory, you'll get the same output.
git check-ignore accepts wildcards at all, since the documentation calls the argument pathname and not pathspec. Update: as @LeGEC pointed out in the comments, the shell is interpreting the pathname, hence the support for wildcards.