Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differencies between git add and git stage command

Tags:

git

People also ask

What is the difference between the git add command and the git commit command?

git add : takes a modified file in your working directory and places the modified version in a staging area. git commit takes everything from the staging area and makes a permanent snapshot of the current state of your repository that is associated with a unique identifier.

What is git stage command?

A staging step in git allows you to continue making changes to the working directory, and when you decide you wanna interact with version control, it allows you to record changes in small commits. Suppose you have edited three files ( a. html , b. html , and c. html ).

What is git add?

The git add command adds a change in the working directory to the staging area. It tells Git that you want to include updates to a particular file in the next commit. However, git add doesn't really affect the repository in any significant way—changes are not actually recorded until you run git commit .

What are the three stages of git?

Git has three main states that your files can reside in: modified, staged, and committed: Modified means that you have changed the file but have not committed it to your database yet.


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


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.