Differencies between git add and git stage command

前端 未结 2 1689
名媛妹妹
名媛妹妹 2021-02-02 05:29

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.

相关标签:
2条回答
  • 2021-02-02 06:25

    To add to torek's answer, that synonym was introduced in 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 --staged alias to 'git diff'). Also adds a doc file for 'git stage' that basically points to the docs for '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"

    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.

    0 讨论(0)
  • 2021-02-02 06:29

    As the documentation says, git stage is just a synonym for git add, so there is no difference in usage.

    0 讨论(0)
提交回复
热议问题