git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

Previous: Yubin RuanNext: Duy Nguyen
Message 2 of 3 in “git glob pattern in .gitignore and git command”
  1. Yubin RuanJun 3, 2018
  2. Philip OakleyJun 3, 2018
  3. Duy NguyenJun 3, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.