Missed Team ’24? Catch up on announcements here.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Staged vs Unstaged

Andy Tarabocchia
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 15, 2015

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

5 answers

1 accepted

51 votes
Answer accepted
Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 15, 2015

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 area 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 definitively 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:

tumendelgere
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 7, 2016

Hi,

 

This is very clean and helpful comments.

Thanks a lot.

 

Like # people like this
David Villacrés
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 23, 2017

Very "clean" explanation. :)

Thanks.

Like vasyl.lukachynets likes this
saad furqan
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 4, 2018

Very good explanation :)

Thanks !! 

John William Schmid
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 7, 2018

Good answer, but you wrote "defintifly".. I think you mean definitively.. Just saying.. please delete this after you fix =D

Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 7, 2018

Voila ... after you staged this orthographical proposal, I commited this to my original post :-)

As I'm not a native english speaker, thanks for your hint!

Like mariolina likes this
Frank Rojas
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 29, 2019

Answer still working :-) after quite many years.

a-a-k
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 2, 2019

Okay, but what about added/deleted files? Now I'm often facing new added files are going right into staged, that is not expected for me. Also, if I unstage them they are getting lost away from index complitely.

3 votes
Andy Tarabocchia
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
December 16, 2015

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

Johannes Kilian
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2015

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

Jinesh Kumat
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 28, 2016

Lai bhari ! 

0 votes
Oyeyinka Onaolapo
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 22, 2020

Great explanation. Very clear and easy to understand. Thanks.

0 votes
Angélica Fuentes
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
September 6, 2018

Thanks!!!  =)

0 votes
Vladimir Kolesar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 18, 2018

Great explanation ! Thanks a los :)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events