git add *(星号)vs git add。 (期)
我是git的新手,我有一个关于在git中添加文件的问题。 我发现了多个关于git add .之间差异的stackoverflow问题git add . 和git add -a , git add --all , git add -A等。但是我一直无法找到解释git add *做什么的地方。 我甚至看过git add man页面,但它没有帮助。 我一直在使用它来代替git add . 我的同事问我为什么。 我没有答案。 我一直使用git add * 。
是git add . 和git add *相同? 是否仅从当前目录添加更改的文件,而另一个是从当前目录和子目录(递归地)添加文件?
有一个伟大的图表列出了其他堆栈问题之一,显示了git add -A git add .之间的区别git add . 和git add -u ,但它没有git add * 。

注意:我明白使用星号作为通配符(添加给定扩展名的所有文件)意味着什么。 例如, git add *.html会添加所有扩展名为.html文件(但忽略.css , .js等)。
谢谢您的帮助!
add *表示添加当前目录中的所有文件,名称以点开头的文件除外。 这是你的shell功能,Git只收到文件列表。
add . 在shell中没有特殊含义,因此Git会递归地添加整个目录,这几乎是相同的,但包括名称以点开头的文件。
*不是git的一部分 - 它是shell解释的通配符。 *扩展到当前目录中的所有文件,然后只传递给git,它将它们全部add 。 . 是当前目录本身, git add它将会添加它以及它下面的所有文件。
使用点. 在shell中通常意味着“当前目录”。
在shell上使用星号*时,会使用名为file-globbing的功能。 例如在bash中,函数glob()就是这样做的。 glob( man 7 glob )的man 7 glob页指出:
描述
Long ago, in UNIX V6, there was a program /etc/glob that would expand
wildcard patterns. Soon afterward this became a shell built-in.
These days there is also a library routine glob(3) that will perform this
function for a user program.
通配符匹配
A string is a wildcard pattern if it contains one of the characters '?', '*' or '['.
通配符
Globbing is the operation that expands a wildcard pattern
into the list of pathnames matching the pattern.
这意味着当您将参数传递给包含'?'的命令行上的任何程序时, , '*'或'[' ,首先通配符将通配符模式扩展为文件列表,然后将这些文件作为参数传递给程序本身。
'git add .'之间'git add .'含义不同'git add .' 和'git add *'由Denis明确描述:
git add期望要添加的文件列表。 在上面的例子中,shell扩展*或. 分别并将结果作为参数提供给git add。 现在区别在于用git add . git将扩展到当前目录,而git add *触发文件通配符,并且扩展到所有不以点开头的文件和目录。
