解释 "git add" 的“-A”标志
Explain "-A" flag of "git add"
有人可以解释 git add
的 -A
标志吗? (--all
, --no-ignore-removal
)
我可以在手册页中看到它是这样说的:
-A, --all, --no-ignore-removal
Update the index not only where the working tree has a file
matching <pathspec> but also where the index already has an entry.
This adds, modifies, and removes index entries to match the working
tree.
If no <pathspec> is given when -A option is used, all files in the
entire working tree are updated (old versions of Git used to limit
the update to the current directory and its subdirectories).
将其翻译成简单的英语为“当您运行执行命令时,无论您在目录树中的什么位置,它都会添加文件”是否正确?这样可以吗?
此外,这是否意味着“一直 运行 git add -A .
只是为了确定”?
这个标志有两种不同的行为。
当前的默认行为是暂存添加和删除。例如,如果您 运行 rm Makefile
,那么使用此选项(或不使用此选项且不使用 --no-all
),Git 将使用 git add Makefile
暂存删除。这比某些路径 运行 git add
和其他路径 git rm
更方便。
如果您未指定要暂存的任何文件,则另一种行为是暂存工作树中已修改的任何位置的所有文件。这等同于您所说的 除了 它要求您不指定任何路径。请注意,如果您编写 git add -A .
,那将不适用,因为在这种情况下,您已经告诉 Git 仅暂存工作目录及其子目录。在这种情况下,-A
只有第一个行为(除非您使用的是非常旧的 Git,否则它无论如何都会有)。
如果您的目标是在工作树中暂存所有更改,而不管您身在何处,只需 运行 git add -A
.
有人可以解释 git add
的 -A
标志吗? (--all
, --no-ignore-removal
)
我可以在手册页中看到它是这样说的:
-A, --all, --no-ignore-removal
Update the index not only where the working tree has a file
matching <pathspec> but also where the index already has an entry.
This adds, modifies, and removes index entries to match the working
tree.
If no <pathspec> is given when -A option is used, all files in the
entire working tree are updated (old versions of Git used to limit
the update to the current directory and its subdirectories).
将其翻译成简单的英语为“当您运行执行命令时,无论您在目录树中的什么位置,它都会添加文件”是否正确?这样可以吗?
此外,这是否意味着“一直 运行 git add -A .
只是为了确定”?
这个标志有两种不同的行为。
当前的默认行为是暂存添加和删除。例如,如果您 运行 rm Makefile
,那么使用此选项(或不使用此选项且不使用 --no-all
),Git 将使用 git add Makefile
暂存删除。这比某些路径 运行 git add
和其他路径 git rm
更方便。
如果您未指定要暂存的任何文件,则另一种行为是暂存工作树中已修改的任何位置的所有文件。这等同于您所说的 除了 它要求您不指定任何路径。请注意,如果您编写 git add -A .
,那将不适用,因为在这种情况下,您已经告诉 Git 仅暂存工作目录及其子目录。在这种情况下,-A
只有第一个行为(除非您使用的是非常旧的 Git,否则它无论如何都会有)。
如果您的目标是在工作树中暂存所有更改,而不管您身在何处,只需 运行 git add -A
.