Saturday 13 July 2019

Git: Different states (staging, committed, modified)


Data in git repository can fall into either of below three states.

a.   Committed
b.   Modified
c.    Staging



Committed state
Data is successfully stored into local database

Modified state
File is changed, but the file data is not yet saved to local database.

Staging state
When you mark a file (or) files to go to your next commit state, those files are in staging state.

Below steps give you more understanding.

a.   Whenever you checked out a git repository, all the files (including files history) is downloaded to local git repository. In this state you have all the information.


b.   Let us assume, there are 8 files (a.txt, b.txt, c.txt, d.txt, e.txt, f.txt, g.txt, h.txt).
c.   You modified b.txt, d.txt, e.txt, g.txt, h.txt. In this case, b.txt, d.txt, e.txt, g.txt, h.txt are in modified state 


d.   Now if you want to commit 3 of the files d.txt, g.txt, h.txt, then move these three files to staging area.

e.   Now you can move these three files to committed state. Once you move these files to committed state, these files (d.txt, g.txt and h.txt) are stored into local database.

f.   To move these changes from local repository to remote repository, you need to push these changes.
Previous                                                    Next                                                    Home

No comments:

Post a Comment