Staged vs Unstaged

What are the differences between files in Staged and Unstaged and what does it mean?

4 answers

1 accepted

This widget could not be displayed.

The staging area (aka index) is a container where git collects all changes which will be part of the next commit.

If you are editing a versioned file on your local machine, git recognizes that your file is modified - but it will not be automatically part of your next commit and is therfore unstaged. Staging the file will put the file into the staging area (index). The next git commit will transfer all items from staging are into your repository.

What is this good for? Imagine you are in hectic and you have to fix a few bugs in your software. Usually you edit your files and fix simultaneously several bugs. After this you have a lot of unstaged but modified files. On the other hand you want to have "clean" commits: each commit should be defintifly related to a single bug only. Using the staging area you could collect all changes referring to a single bug and make a clean commit - in your next step you stage all changes for the next bug and make the next clean commit ...

You could not only stage complete files - but also "hunks" (parts of a file) and even single lines from a modified file (sourcetree is a great tool for preparing the staging area with great facilities for staging files, hunks or lines).

Resumee: Editing a versioned file makes the file modified, but unstaged. Staging the file/hunk/line adds the change to the staging area. The changes within the staging area are part of the next commit. The commit transfers all changes from staging area into your repository. The staging area allows you to collect all changes to get a "clean" commit.

Hope this was clear

 

See:

Hi,

 

This is very clean and helpful comments.

Thanks a lot.

 

Very "clean" explanation. :)

Thanks.

Very good explanation :)

Thanks !! 

This widget could not be displayed.

This helped! Thank you so much for the explanation and links!

Glad I could help you. You might mark my answer as accepted as well ....

Lai bhari ! 

This widget could not be displayed.

Great explanation ! Thanks a los :)

This widget could not be displayed.

Thanks!!!  =)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

879 views 2 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you