{"thread":{"id":"48631","subject":"git glob pattern in .gitignore and git command","startedAt":"2018-06-03T00:58:44Z","lastAt":"2018-06-03T17:43:46Z","messageCount":3,"participants":["Yubin Ruan","Philip Oakley","Duy Nguyen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"349106","messageId":"20180603005834.rwl5mx7llrv767xn@HP","threadId":"48631","inReplyTo":null,"subject":"git glob pattern in .gitignore and git command","fromName":"Yubin Ruan","fromEmail":"ablacktshirt@gmail.com","sentAt":"2018-06-03T00:58:34Z","receivedAt":"2018-06-03T00:58:44Z","isPatch":false,"sender":{"key":"ablacktshirt@gmail.com","avatar":null},"body":"To ignore all .js file under a directory `lib', I can use \"lib/**/js\" to match\nthem. But when using git command such as \"git add\", using \"git add lib/\\*.js\"\nis sufficient. Why is this difference in glob mode?\n\nI have heard that there are many different glob mode out there (e.g., bash has\nmany different glob mode). So, which classes of glob mode does these two\nbelong to? Do they have a name?\n\nYubin\n"},{"id":"349179","messageId":"CE0F075DBC5A41FE87088A8E6B754D32@PhilipOakley","threadId":"48631","inReplyTo":"20180603005834.rwl5mx7llrv767xn@HP","subject":"Re: git glob pattern in .gitignore and git command","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2018-06-03T17:34:09Z","receivedAt":"2018-06-03T17:34:29Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"Hi Yubun,\n\nFrom: \"Yubin Ruan\" <ablacktshirt@gmail.com>\n> To ignore all .js file under a directory `lib', I can use \"lib/**/js\" to\n> match\n> them. But when using git command such as \"git add\", using \"git add\n> lib/\\*.js\"\n> is sufficient. Why is this difference in glob mode?\n>\n> I have heard that there are many different glob mode out there (e.g., bash\n> has\n> many different glob mode). So, which classes of glob mode does these two\n> belong to? Do they have a name?\n>\n\nIs this a question about `git add` being able to add a file that is marked\nas being ignored in the .gitignore file? [Yes it can.]\n\nOr, is this simply about the many different globbing capabilities of one's\nshell, and of Git?\n\nThe double asterix (star) is specific/local to Git. It is described in the\nvarious commands that use it, especially the gitignore man page `git help\nignore` or  https://git-scm.com/docs/gitignore.\n\"Two consecutive asterisks (\"**\") in patterns matched against full pathname\nmay have special meaning: ... \"\n\nThe single asterix does have two modes depending on how you quote it. It is\ndescribed in the command line interface (cli) man page ` git help cli` or\nhttps://git-scm.com/docs/gitcli.\n\"Many commands allow wildcards in paths, but you need to protect them from\ngetting globbed by the shell. These two mean different things: ... \"\n\nA common proper name for these asterix style characters is a \"wildcards\".\nTry 'bash wildcards' or linux wildcards' in your favourite search engine.\n\n--\nPhilip\n\n"},{"id":"349180","messageId":"CACsJy8Ar93y19JuYK+_NDQOn=4+8EH6e+9vWOQZNMGnLgExF-w@mail.gmail.com","threadId":"48631","inReplyTo":"20180603005834.rwl5mx7llrv767xn@HP","subject":"Re: git glob pattern in .gitignore and git command","fromName":"Duy Nguyen","fromEmail":"pclouds@gmail.com","sentAt":"2018-06-03T17:43:12Z","receivedAt":"2018-06-03T17:43:46Z","isPatch":false,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Sun, Jun 3, 2018 at 2:58 AM, Yubin Ruan <ablacktshirt@gmail.com> wrote:\n> To ignore all .js file under a directory `lib', I can use \"lib/**/js\" to match\n> them. But when using git command such as \"git add\", using \"git add lib/\\*.js\"\n> is sufficient. Why is this difference in glob mode?\n\nHistorical reasons mostly. '**' comes later when '*' already\nestablishes its place. You can use '**' too with \"git add\n':(glob)lib/**/*.js'\". See\nhttps://git-scm.com/docs/gitglossary#gitglossary-aiddefpathspecapathspec\n-- \nDuy\n"}]}