-A
选项会添加、修改和删除索引条目以匹配工作树。-A
选项现在是默认的。.
时,更新的范围限制在当前目录下,根据Git documentation。我讨厌git的暂存机制,其他版本控制工具中也找不到这种机制。
所以我总是使用:
\git add --all && \git commit --all
(即使只用\git add --all
,\git commit
已经足够了)
对于add
:
--no-ignore-removal --all | add, modify, and remove index entries to match the working tree
--ignore-removal --no-all | add, modify index entries to match the working tree
--intent-to-add | add an entry for the path to the index, with no content
-A
是 --all
的缩写
git add <pathspec>
等同于:对于 Git 的版本 2.35.1:git add --all <pathspec>
旧版本的 Git: git add --no-all <pathspec>
但是,git add
后面什么也不跟时,并不等同于 git add --all
,而是什么也不做:
git add --all
(省略<pathspec>
):处理整个工作树中的所有文件(旧版本的Git仅限于当前目录及其子目录)。
告诉命令自动暂存已修改和删除的文件,未告知Git的新文件不受影响。