DevOps
Git
Workflow & States

Workflow & States

To understand Git, you must understand the Three States a file can reside in and the Three Areas of a Git project.

1. The Three States

  • Modified: You have changed the file but have not committed it to your database yet.
  • Staged: You have marked a modified file in its current version to go into your next commit snapshot.
  • Committed: The data is safely stored in your local repository.

2. The Three Areas (Local)

These states correspond to three physical areas on your machine:

  1. Working Directory: A single checkout of one version of the project. These files are pulled out of the compressed database and placed on your disk for you to use.
  2. Staging Area (Index): A file, generally contained in your Git directory, that stores information about what will go into your next commit.
  3. Local Repository (.git folder): Where Git stores the metadata and object database for your project. This is what is copied when you clone a repository.

3. The Remote Area

  1. Remote Repository: A version of your project that is hosted on the internet or network somewhere (e.g., GitHub).

Visualizing the Flow


[!IMPORTANT] The Staging Area is Unique Many other VCS tools don't have a staging area. Git's staging area allows you to carefully craft your commit, choosing exactly which changes (or even which lines!) to include in the next snapshot.