Staging area, working tree, and HEAD commit

Until now, we have barely named the staging area (also known as an index), while preparing files to make a new commit with the git add command.

Well, the staging area purpose is actually this. When you change the content of a file, when you add a new one or delete an existing one, you have to tell Git what of these modifications will be part of the next commit: the staging area is the container for this kind of data.

Let's focus on this right now; move to the master branch, if not already there, then type the git status command; it allows us to see the actual status of the staging area:

[1] ~/grocery (master)
$ git status
On branch master
nothing to commit, working tree clean

Git says there's nothing ...

Get Git Essentials - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.