How Git works

Git has three main states that your files or artifacts can reside in

  1. modified  >  Modified means that you have changed the artifact but have not committed it to your git database yet
  2. staged  > Staged means that you have marked a modified file in its current version to go into your next commit snapshot. Snapshot means “state of an artifact at any point of time”. This is achieved by the “git add” command.
  3. committed > Committed means that the artifact such as file data is safely stored in your local Git database. This is achieved by the “git commit” command.

In later lectures we will actually execute the commands such as “git add” and “git commit” directly on the command line. So as per Git workflow, the artifact state sequentially moves from modified and then to staged and subsequently to committed state based on commands issued the developer.

I would like to stress on the fact that we have used the command line in our later lectures since git was originally designed to be a command line tool. Currently we have many Git related GUI tools in the market. However working with command line gives us greater grasp and insight into the subject matter.

So we have three main sections of a Git project: 

  1. working directory  >  this is the section where you work on your files – for example, you might create a file and modify it
  2. staging area .> This is the section where the changes in artifact are marked for commit. It’s sometimes referred to as the “index” . 
  3. commit area  > Commit area is the most important part of Git. This is where committed files are stored.The .git directory is where Git stores the committed artifacts and metadata  for your project. Metadata is nothing but data about data.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top