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

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

问题描述

我是 git 新手,我有一个关于在 git 中添加文件的问题.我发现了多个关于 git add .git add -agit add --allgit 之间区别的 stackoverflow 问题add -A 等.但我一直无法找到解释 git add * 功能的地方.我什至查看了 git add 手册页,但没有帮助.我一直在用它代替 git add .,我的同事问我为什么.我没有答案.我只是一直使用 git add *.

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 *.

git add .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)?

在其他堆栈问题之一上列出了一个很棒的图表,显示了 git add -A git add .git add -u<之间的区别/code>,但它没有 git add *.

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 *.

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

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).

感谢您的帮助!

推荐答案

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

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 . 在您的 shell 中没有特殊含义,因此 Git 递归添加整个目录,这几乎相同,但包括名称以点开头的文件.

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天全站免登陆