git add *(星号)vs git add。 (期) [英] git add * (asterisk) vs git add . (period)

查看:695
本文介绍了git add *(星号)vs git add。 (期)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,我有一个关于在git中添加文件的问题。我发现了有关 git add。 git add -a git add --all , git add -A 等等,但是我一直无法找到解释 git add * 的确如此。我甚至看过 git添加手册页,但它没有帮助。我一直在用它来代替 git add。,我的同事问我为什么。我没有答案。我一直使用 git add *


$ b $ < git add。和 git add * 相同?是否仅从当前目录添加更改的文件,而另一个是从当前目录和子目录(递归地)添加文件?



有一个很棒的图表列在其中一个其他堆栈问题显示 git add -A git add。 git add之间的区别-u ,但它没有 git add *





注意:我明白这意味着什么使用星号作为通配符(添加给定扩展名的所有文件)。例如, git add * .html 会添加所有具有 .html 扩展名的文件(但忽略 .css .js 等)。



感谢您的帮助!

解决方案

add * 表示添加当前目录中的所有文件,名称以点开头的文件除外。这是你的shell功能,Git只接收文件列表。



add。没有特殊含义你的shell,因此Git递归地添加整个目录,这几乎是相同的,但包括名称以点开头的文件。


I'm new to git and I have a question about adding files in git. I have found multiple stackoverflow questions about the difference between git add . and git add -a, git add --all, git add -A, etc. But I've been unable to find a place that explains what git add * does. I've even looked at the git add man page, but it didn't help. I've been using it in place of git add . and my co-worker asked me why. I didn't have an answer. I've just always used git add *.

Are git add . and git add * the same? Does one add changed files from the current directory only, while the other adds files from the current directory and subdirectories (recursively)?

There's a great chart listed on one of the other stack questions that shows the difference between git add -A git add . and git add -u, but it doesn't have git add *.

Note: I understand what it means to use the asterisk as a wildcard (add all files with a given extension). For example, git add *.html would add all files that have a .html extension (but ignore .css, .js, etc).

Thanks for the help!

解决方案

add * means add all files in the current directory, except for files, whose name begin with a dot. This is your shell functionality and Git only ever receives a list of files.

add . has no special meaning in your shell, and thus Git adds the entire directory recursively, which is almost the same, but including files whose names begin with a dot.

这篇关于git add *(星号)vs git add。 (期)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆