Re: git glob pattern in .gitignore and git command
- From
Philip Oakley <philipoakley@iee.org>
- Date
- Jun 3, 2018, 17:34 UTC
- Message-ID
- <CE0F075DBC5A41FE87088A8E6B754D32@PhilipOakley>
- In-Reply-To
- <20180603005834.rwl5mx7llrv767xn@HP>
Hi Yubun,
From: "Yubin Ruan" <ablacktshirt@gmail.com>
Show 11 quoted lines
> To ignore all .js file under a directory `lib', I can use "lib/**/js" to > match > them. But when using git command such as "git add", using "git add > lib/\*.js" > is sufficient. Why is this difference in glob mode? > > I have heard that there are many different glob mode out there (e.g., bash > has > many different glob mode). So, which classes of glob mode does these two > belong to? Do they have a name? >
Is this a question about `git add` being able to add a file that is marked as being ignored in the .gitignore file? [Yes it can.]
Or, is this simply about the many different globbing capabilities of one's shell, and of Git?
The double asterix (star) is specific/local to Git. It is described in the various commands that use it, especially the gitignore man page `git help ignore` or https://git-scm.com/docs/gitignore. "Two consecutive asterisks ("**") in patterns matched against full pathname may have special meaning: ... "
The single asterix does have two modes depending on how you quote it. It is described in the command line interface (cli) man page ` git help cli` or https://git-scm.com/docs/gitcli. "Many commands allow wildcards in paths, but you need to protect them from getting globbed by the shell. These two mean different things: ... "
A common proper name for these asterix style characters is a "wildcards". Try 'bash wildcards' or linux wildcards' in your favourite search engine.
-- Philip