git add 和 git stage 命令的区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34175799/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Differencies between git add and git stage command
提问by torek
What is the difference between git add filename
and git stage filename
? Because when I tried them both it looks that they do the same thing.
git add filename
和 和有什么不一样git stage filename
?因为当我尝试它们时,看起来它们做同样的事情。
回答by torek
As the documentation says, git stage
is just a synonym for git add
, so there is no difference in usage.
正如文档所说,git stage
只是 的同义词git add
,因此在用法上没有区别。
回答by VonC
To add to torek's answer, that synonym was introduced in commit 11920d2 (git 1.6.1-rc2, Dec. 2008)
为了补充torek的答案,该同义词是在commit 11920d2 (git 1.6.1-rc2, Dec. 2008) 中引入的
Add a built-in alias for '
stage
' to the 'add
' commandThis comes from conversation at the GitTogether where we thought it would be helpful to be able to teach people to 'stage' files because it tends to cause confusion when told that they have to keep 'add'ing them.
This continues the movement to start referring to the index as a staging area (eg: the
--staged
alias to 'git diff
'). Also adds a doc file for 'git stage
' that basically points to the docs for 'git add
'.
将“ ”的内置别名添加
stage
到“add
”命令这来自 GitTogether 的谈话,我们认为能够教人们“暂存”文件会很有帮助,因为当被告知他们必须继续“添加”文件时,这往往会引起混淆。
这将继续开始将索引称为暂存区的运动(例如:
--staged
“git diff
”的别名)。还为“git stage
”添加了一个文档文件,该文件基本上指向“git add
”的文档。
That latter influenced the git status
output, in commit 8009d83, git 1.7.4-rc0, Nov 2010.
The message "Changed but not updated
" was rewritten into "Changes not staged for commit
"
后者影响了git status
输出,在commit 8009d83, git 1.7.4-rc0, Nov 2010 中。
消息“ Changed but not updated
”被改写为“ Changes not staged for commit
”
Better "
Changed but not updated
" message ingit status
Older Gits talked about "updating" a file to add its content to the index, but this terminology is confusing for new users.
"to stage
" is far more intuitive and already used in e.g. the "git stage
" command name.
更好的“
Changed but not updated
”消息git status
较旧的 Git 谈到“更新”文件以将其内容添加到索引中,但是这个术语对于新用户来说是令人困惑的。
"to stage
" 更直观,并且已经在例如 "git stage
" 命令名称中使用。