The three main sections of a project
Using Git requires to keep in mind the three main sections of a Git project: the working directory, the staging area, and the Git directory:
- the working directory is the directory of your Git project in which files pulled out of the Git directory are placed for you to use and modify. It represents one version of the project waiting for you to edit it;
- the staging area is a place in the Git directory where the changes
that will comprise the next commit (the next recorded state of your project)
are kept. It is also called the
indexin Git parlance;
- the Git directory is the
.gitspecial subdirectory of your Git project directory where all the meta information and the object database of your project are stored. This is the core of Git and is what is copied when you clone a repository from a remote Git repository.
The three main states of a file
It emerges that a file of a Git project can reside in three main states: modified, staged, and committed:
- a file is modified when it was changed in the working directory but not committed in the database stored in the Git directory;
- a file is staged when it was modified and these new changes were marked to go into the next commit snapshot: they are added to the staging area, also called the index (files in this state are thus also sometimes said indexed);
- a committed file is a file whose changes are safely stored in the local database of your Git project, kept in the Git directory.