[英]What's the difference between git add * and git add ., if any?
git animals had this series of commands: git animals有这一系列命令:
git init
git add *
git commit -a -m ‘initial commit and release!’
What does git add *
do compared to git add .
与git add *
相比, git add .
git add *
做了什么git add .
(which I normally do) are they the same? (我通常这样做)他们是一样的吗?
git add *
will add all the paths that are the result of the shell expansion of *
whereas git add .
git add *
将添加所有可在外壳膨胀的结果的路径*
而git add .
will tell git to add the current directory. 将告诉git添加当前目录。
git add *
won't add paths that begin with a .
git add *
不会添加以a开头的路径.
as the shell expansion of *
considers these to be "hidden" paths. 因为*
的shell扩展认为这些是“隐藏”的路径。
git add *
will also fail if any expanded path is currently being ignored by git because git considers it an error if you explicitly specify an ignored path without passing the -f
(force) flag to show that you really want to add an ignored path. 如果git当前正在忽略任何扩展路径, git add *
也会失败,因为如果你明确指定一个被忽略的路径而没有传递-f
(强制)标志来表明你真的想要添加一个被忽略的路径,git认为这是一个错误。
If you get git to expand the glob ( git add '*'
) it will add "hidden" files and skip over ignored files. 如果你得到git来扩展glob( git add '*'
),它将添加“隐藏”文件并跳过忽略的文件。 It would work the same as git add .
它会像git add .
一样工作git add .
in this case. 在这种情况下。
By default passing a directory to git add
will recursively add its sub-directories and files. 默认情况下,将目录传递给git add
会递归添加其子目录和文件。
The wildcard *
will be expanded by your shell as files' names below current directory. 通配符*
将由shell扩展为当前目录下的文件名。
And you know, in Unix .
你知道,在Unix中.
refers only to the current directory, so these two commands are equivalent. 仅指当前目录,因此这两个命令是等效的。 Though *
is processed by the shell and .
虽然*
是由shell处理的.
is processed by git, they do the same thing. 由git处理,他们做同样的事情。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.