Reading time: 50 seconds
As far as the Git workflow is concerned, there are three pieces of Git that we should be aware of before moving forward with some slightly more complex (but totally doable!) explanation.
Let’s cover each one in a bit more detail.
A repository is a collection of commits, and a record of what the project’s working tree looked like at one time. You can access the history of commits via the Git log.
There’s always a current starting point in a repository and that’s called the HEAD. A repository also contains tags and branches.
The job of the repository is to be the container that tracks the changes to your project files.
This is a directory on your file system that is associated with a repository.
You can think of this as the filesystem manifestation of the repository. It’s full of the files you edit, where you add new files, and from which you remove unneeded files. Any changes to the Working Tree are noted by the Index (see below), and show up as modified files.
This is a middle area that sits between your Git repository and your Working Tree.
The Index keeps a list of the files Git is tracking and compares them to your Working Tree when you make changes. These changed files show up as modified before you bundle them up into a commit.
You might have heard this called the staging area where changes go before they are committed to the repository as commit objects.
If you ever use the
-a flag when committing, then you are effectively bypassing the Index by turning your changes directly into a commit without staging them first.