Possible Duplicate:
git add -A, git commit in one command?
如果我没有理解错的话,当使用 git 将新文件添加到目录时,我必须调用多个命令来确保文件已提交:
git add <directory name>
git commit -m 'commit comment'
这听起来不对,因为我知道我(和许多其他人)会忘记调用 git add <directory name>
然后以一个缺少所有创建的新文件的项目结束。看来我应该能够在一个命令中提交整个目录,包括任何和所有新文件,而不必在上一个命令中指定将所有新文件添加到提交中。我该怎么做?
git commit -a
将提交 git 已知的所有文件:
-a, --all
Tell the command to automatically stage files that have been modified and
deleted, but new files you have not told git about are not affected.
如果你想确保你提交了你想提交的所有内容,你可以在 git-commit
之前使用 git-status
来查看文件为提交而准备的。
git
使用两阶段过程将更改从工作目录
获取到存储库
。像 git commit -a
这样的包罗万象的方法 会 起作用,但它会导致困惑的、非原子的提交。我会提倡较小的、集中的提交,而不是使用您正在寻找的包罗万象的方法。
This doesn't sound right because I know I (and many other people) will forget to call git add...
git-status
是你的 friend :)
注意:git-add
不会将文件添加到存储库。 git commit
从 staging area
repository
提交东西,不 working area
。乍一看这似乎很奇怪,但提供了更大的灵 active 。参见 another answer想要查询更多的信息。