提交所有文件忽略 .gitignore 中的文件?

Commiting all files ignores the ones in .gitignore?

我是 Git 的新人,所以我的问题是:

使用

git commit -a -m "Message"

会尊重 .gitignore 文件吗?如果我运行

git add *

它说不能这样做,因为有文件被更改并标记为忽略。

git-commit 中的 -a 标志不会提交工作目录中的所有文件,仅提交存储库中 已经存在 的文件已经改变了。这与 git add * 不同,后者使用 * 的 shell 扩展将所有文件添加到暂存中,甚至包括 git 之前未管理的文件。

(From git-commit man page)

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