When working with a git repository, your project constantly cycles between these three environments:
- Working directory
- Staging Area
- Repository
Working Directory
In the working directory, the changes you make to files and folders aren’t recorded by your version control software (git). For git to track the changes you make, you need to use the command git add [filename(s)]
which will move your changes to the staging area.
Staging Area
The staging area also referred to as the ‘index’ is a collection of files and folders that git is tracking and includes changes that will eventually be committed.
Repository
The repository stores all the commits you have ever made in your project and you can quickly revert back to any commit you made in the past. From the staging area, use the command git commit -m 'your commit message'
to create a new commit.