Differencies between git add and git stage command

Git

Git Problem Overview


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 Solutions


Solution 1 - Git

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

Solution 2 - Git

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.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser3053231View Question on Stackoverflow
Solution 1 - GittorekView Answer on Stackoverflow
Solution 2 - GitVonCView Answer on Stackoverflow