What is the effect of git commit without the -a option?

爷,独闯天下 提交于 2019-12-18 12:12:21

问题


What is the difference between these two commands?

git commit -m "added a new page"

and

git commit -a -m "added a new page"

I know that the -a option will stage files that have been modified and deleted, but then what does running it without the -a mean?


回答1:


You have to explicitly stage changes for commitment by using git add or git rm.

If you use the -a flag when doing a commit, git will automatically stage any modified and removed files without you having to explicitly stage them using add or rm, etc.

If you don't specify -a, any files that have been modified or removed, but not explicitly staged using git add or git rm will be ignored in the commit.

update

As Dr. Gianluigi Zane Zanettini says - -a does not add new files to the index, so if you have completely new files you shouldn't expect -a to ad them.

http://www.kernel.org/pub/software/scm/git/docs/git-commit.html



来源:https://stackoverflow.com/questions/2807899/what-is-the-effect-of-git-commit-without-the-a-option

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!