git add . vs git commit
What's the difference between:
git add .
git commit -a
Should I be doing both, or is that redundant?
git commit -a
means almost[*] the same thing as git add -u && git commit
.
It's not the same as git add .
as this would add untracked files that aren't being ignored, git add -u
only stages changes (including deletions) to already tracked files.
[*] There's a subtle difference if you're not at the root directory of your repository. git add -u
stages updates to files in the current directory and below, it's equivalent to git add -u .
whereas git commit -a
stages and commits changes to all tracked files.
git commit -a
automatically invokes git add
on all files it knows about. You can use git add
to select what files to commit. Consult the docs for more info: here
通过使用git commit -a开关和commit命令来自动“添加”来自所有已知文件的更改(即,已经在索引中列出的所有文件)
链接地址: http://www.djcxy.com/p/7908.html