Git has three main states that your files can reside in it. They are Committed, Modified, Staged. What are they? and how does the git workflow go?

Committed

The data is safely stored in your local Git database. The database is located in the Git directory, which stores the metadata and object database the whole project. It is what you push/clone a repository to/from another computer.

Modified

The file has been changed but not committed to Git database yet, the modified file is in the working directory, where it's a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directoryand placed on disk for you to use or modify.

Staged

The file has been marked in current version, and will go into the next commit snapshot. Staged file has snapshots stores in staging area, where it's a file, stores information about what will go into your next comit. It's sometimes referred to as the 'index', but it's also common to refer to it as the staging area. It is contained in your Git directory

How does the basic Git workflow go?

1. You init or clone a project, one of version goes to working directory
2. You modify files stay in working directory.
3. You stage the files, adding snapshots of them to your staging area.
4. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

If a particular version of a file is in the Git directory, it's considered committed.

If a file is modified but has been added to the staging area, it is staged.

While if it was changed since it was checked out but not yet staged, it is modified.

 

 

 

 

 

 

 

 

 

Comments powered by CComment