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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 11:37:08  来源:igfitidea点击:

Differencies between git add and git stage command

git

提问by torek

What is the difference between git add filenameand 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 stageis 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' command

This 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 --stagedalias to 'git diff'). Also adds a doc file for 'git stage' that basically points to the docs for 'git add'.

将“ ”的内置别名添加stage到“ add”命令

这来自 GitTogether 的谈话,我们认为能够教人们“暂存”文件会很有帮助,因为当被告知他们必须继续“添加”文件时,这往往会引起混淆。

这将继续开始将索引称为暂存区的运动(例如:--stagedgit diff”的别名)。还为“ git stage”添加了一个文档文件,该文件基本上指向“ git add”的文档。



That latter influenced the git statusoutput, 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 in git 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" 命令名称中使用。