Understanding git working areas

okoth kongo
2 min readApr 12, 2021

A friend once asked me to explain git to him. I believe that understanding the git working areas is the key to understanding git. I am not a fan of the dictionary definition and prefer analogies and stories.

This explanation assumes you have git set up in your machine. If not, I have attached a cheat sheet to guide you on how to do so.

Git is a version control system, there are lots of them but git is the most popular one.

Git has three working areas:

- working directory

- staging area

- repository

I view the git working areas as the relationship stages.

We will use the git statuscommand to check the status of this relationship all through.

Working directory

When your work is still in the working directory(WD) assuming you it is being born and still underage, that you still in your editor new typing things. If you check its status. It shows you see red on the terminal. You cannot date a child or have a relationship with them. Red is the danger sign, my friend.

You can move your work from childhood to adulthood using the git addcommand. This command moves it to the staging area

Check out how to work with the git add command and its options in the cheat sheet

Staging area

In this area, if you check the status of your work you will see green, meaning he/she can date but not committed to anyone yet. Meaning he/she can be taken by anyone, anyone, in this case, is the branch. Let’s say you have dated for a while and you see fit to make it serious(you are satisfied with your work ) you commit. The commitment is done using git commit -m “will you marry me"

Kindly note -m option added when commit you must commit with a message right?, This message can be anything in our case it “will you marry me”, but mostly it should be something which best describes what you working on, for instance, “validate user email and password”

Repository/repo

As you will guess from its name repo means database/storage. Once commit your relationship/work is safely stored.

If you check the status, see nothing the guy/lady is not available sorry.

The attached cheat sheet belongs to GitHub education.

https://education.github.com/git-cheat-sheet-education.pdf

--

--