gpt4 book ai didi

git - 为什么 "git add *"不添加 "git status"表示未暂存的文件?

转载 作者:太空狗 更新时间:2023-10-29 14:32:44 26 4
gpt4 key购买 nike

当我打字时

git add *

它就像没有添加文件一样,但是当我添加时

git status

它显示未暂存的文件。我可以通过手动输入名称来暂存它们,如图所示,但在相同情况下这需要相当长的时间。

我的问题是,为什么在这种情况下,我不能只输入“git add *”来添加未暂存的文件,我应该如何解决这个问题?提前谢谢你。

这张图片显示了我遇到的行为 http://i.imgur.com/YjqZ85P.png

最佳答案

如果要添加所有文件,请不要使用“*”(由 shell 解释)

git add .

git add -u 将添加更新的文件。 git add -A . 结合了两者。
参见“What's the difference between git add . and git add -u?
还有“Difference between “git add -A” and “git add .””:

. 表示命令在当前子目录而不是整个工作树中运行。

如果你想知道一个文件是否被忽略:git check-ignore -v -- yourFile


如“What's the difference between git add * and git add ., if any?”中所述:

git add * will add all the paths that are the result of the shell expansion of * whereas git add . will tell git to add the current directory.

git add * won't add paths that begin with a . as the shell expansion of * considers these to be "hidden" paths.

torek解释 in the comments为什么“*”在此特定场景中失败:

in this particular case, git add * becomes

git add Bootstrap afile bfile ... index.php main.js ... zfile

or some such, and git add * stops with a fatal error because you told it:

  • "don't add Bootstrap via .gitignore", and
  • "do add Bootstrap via explicit path"

It does not know which to obey, so it does nothing at all.

关于git - 为什么 "git add *"不添加 "git status"表示未暂存的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24949979/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com