All of lore.kernel.org
 help / color / mirror / Atom feed
* git glob pattern in .gitignore and git command
@ 2018-06-03  0:58 Yubin Ruan
  2018-06-03 17:34 ` Philip Oakley
  2018-06-03 17:43 ` Duy Nguyen
  0 siblings, 2 replies; 3+ messages in thread
From: Yubin Ruan @ 2018-06-03  0:58 UTC (permalink / raw)
  To: git; +Cc: Geekaholic

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?

Yubin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git glob pattern in .gitignore and git command
  2018-06-03  0:58 git glob pattern in .gitignore and git command Yubin Ruan
@ 2018-06-03 17:34 ` Philip Oakley
  2018-06-03 17:43 ` Duy Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Philip Oakley @ 2018-06-03 17:34 UTC (permalink / raw)
  To: Yubin Ruan, Git List; +Cc: Geekaholic

Hi Yubun,

From: "Yubin Ruan" <ablacktshirt@gmail.com>
> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: git glob pattern in .gitignore and git command
  2018-06-03  0:58 git glob pattern in .gitignore and git command Yubin Ruan
  2018-06-03 17:34 ` Philip Oakley
@ 2018-06-03 17:43 ` Duy Nguyen
  1 sibling, 0 replies; 3+ messages in thread
From: Duy Nguyen @ 2018-06-03 17:43 UTC (permalink / raw)
  To: Yubin Ruan; +Cc: Git Mailing List, Geekaholic

On Sun, Jun 3, 2018 at 2:58 AM, Yubin Ruan <ablacktshirt@gmail.com> wrote:
> 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?

Historical reasons mostly. '**' comes later when '*' already
establishes its place. You can use '**' too with "git add
':(glob)lib/**/*.js'". See
https://git-scm.com/docs/gitglossary#gitglossary-aiddefpathspecapathspec
-- 
Duy

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-06-03 17:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-03  0:58 git glob pattern in .gitignore and git command Yubin Ruan
2018-06-03 17:34 ` Philip Oakley
2018-06-03 17:43 ` Duy Nguyen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.