2026 Community Survey results are here! See how the Craft CMS community works. results are live!

The Pieces of Git

There are three pieces of Git that we should be aware of before moving forward.

Image

As far as the Git work­flow is con­cerned, there are three pieces of Git that we should be aware of before mov­ing for­ward with some slight­ly more com­plex (but total­ly doable!) explanation.

They are:

  • Repos­i­to­ry
  • Index
  • Work­ing Tree

Let’s cov­er each one in a bit more detail.

Repos­i­to­ry

A repos­i­to­ry is a col­lec­tion of com­mits, and a record of what the project’s work­ing tree looked like at one time. You can access the his­to­ry of com­mits via the Git log.

There’s always a cur­rent start­ing point in a repos­i­to­ry and that’s called the HEAD. A repos­i­to­ry also con­tains tags and branches.

The job of the repos­i­to­ry is to be the con­tain­er that tracks the changes to your project files.

Work­ing Tree

This is a direc­to­ry on your file sys­tem that is asso­ci­at­ed with a repository. 

You can think of this as the filesys­tem man­i­fes­ta­tion of the repos­i­to­ry. It’s full of the files you edit, where you add new files, and from which you remove unneed­ed files. Any changes to the Work­ing Tree are not­ed by the Index (see below), and show up as mod­i­fied files.

Index

This is a mid­dle area that sits between your Git repos­i­to­ry and your Work­ing Tree.

The Index keeps a list of the files Git is track­ing and com­pares them to your Work­ing Tree when you make changes. These changed files show up as mod­i­fied before you bun­dle them up into a commit.

You might have heard this called the stag­ing area where changes go before they are com­mit­ted to the repos­i­to­ry as com­mit objects. 

If you ever use the -a flag when com­mit­ting, then you are effec­tive­ly bypass­ing the Index by turn­ing your changes direct­ly into a com­mit with­out stag­ing them first.