Site icon TestingDocs.com

What are Unstaged and Staged changes in Git?

In this post, we will understand what unstaged and staged changes w.r.t Git version control.

Unstaged vs Staged changes

Unstaged changes are changes that are not tracked by the Git. For example, if you copy a file or modify the file. Git maintains a staging area(also known as index) to track changes that go in your next commit.

 

 

 

The staging area is a file, in your Git directory, that stores information about what will go into your next commit. Staging the changes will put the files into the index. The next git commit will transfer all items from staging into your repository.

Command-line

/> git status

The above command will tell you about untracked files. You can use git add command to add files to the index.

 

Git GUI

You can use Git GUI to know what files are unstaged and staged changes or the Eclipse plugin as shown in the picture.

/> git gui

 

 

Git gui show unstaged/staged changes and you can move files between stage/unstage by using the menu items in the UI.

If you use the Eclipse plugin, you add the files that you wish to commit to the index. Right-click >> Choose Add to index option. Once you have added, you can see that the files will be staged for the next commit.

 

 

Common mistake

The common mistakes when committing changes to the git repository happens when we try to commit an empty index. i.e when there are no staged changes. Commit will not happen as there is nothing to commit.

 

 

Stashing Changes it Git

https://www.testingdocs.com/stashing-changes-it-git/

Git Tutorial Links

https://www.testingdocs.com/git-tutorials/

For more information on Git tool, visit the official website:

https://git-scm.com/

Exit mobile version