Understanding git statuses, storage areas and useful daily git commands

Ko Kyaw
3 min readJul 7, 2021

--

Understanding git statuses, storage areas

Let’s start from a little bit of understand how git works. As git is one of the distributed version control system, it has Local Repository and Remote Repository. So, git maintain the files with the statuses and how where the files will be stored in each stage.

Git File Statuses

Git File Statuses

Basically, git has 4 stages as below

  1. Untracked
  2. Unmodified
  3. Modified
  4. Staged
  5. Untracked

The file(s) that is newly added to the working directory and before adding into git are marked as untracked. This file(s) will be tracked once it is added to git using the command git add <file>.

2. Unmodified

The file(s) that are already being tracked by git and they have no differences between working directory and repository are marked as unmodified.

3. Modified

This is just opposite of Unmodified. The file(s) that are already being tracked by git and have one or more changes in working directory.

4. Staged

The file(s) that are added to git after modified or newly created are marked as staged.

Git File Transition

Git File Transition

There are 4 main storage areas that git store the files based on the it statuses and user actions.

  1. Working Directory
  2. Staging Area
  3. Local Repository
  4. Remote Repository
  5. Working Directory

Basically, Working Directory is a place where you clone and store the data from Remote Repository. This directory will be the working directory which you will be dealing/working with.

2. Staging Area

This files/changes will be stored in staging area when you do git add after file is modified or newly added. This storage area is mainly used to store the files which have been added and have not been committed to git.

3. Local Repository

This files/changes will be stored in local repository when you commit the changes that has been added to the git before. That means files are already in local repository.

4. Remote Repository (Server)

The files/changes will be stored in remote repository when you do push from local repository. Basically, you are safe now the changes are in the server.

Useful daily git commands

Here are the git commands that you need for your daily work.

  • git clone
  • git pull
  • git status
  • git add
  • git commit
  • git push
  • git checkout
  • git merge
  • git diff
  • git log

git clone

Git clone is the thing that you will do at the very beginning to clone the remote repository to your working directory via HTTP or SSH.

git clone <repo url>

git pull

Uses git pull to get the latest changes from remote repository to you working directory.

git pull

git status

To check the current status of the files to see which files are in which staged such as untracked, modified, unmodified or staged.

git status

git add

To stage all the changes in directory or file for the next commit.

git add <directory>
git add <file>

git commit

To commit the file changes in the staged snapshot to the local repository.

git commit -m "You message here"

git push

To push the changes that have been committed before. This will be push the commit from local repository to remote repository. This command can also be used to push new branch, tags and so on. Basically to push the changes from local repository to remote repository.

git push

git checkout

To checkout or switch to the another branch or to create new branch. With -b parameter will create new branch in local repository.

git checkout <existing_branch>
git checkout -b <new_branch>

git merge

To merge a branch to current branch.

git merge <branch>

git diff

Show unstaged changes between working directory and staged area.

git diff
git diff <file>

git log

List entire commit history. Can limit number of history using -<number>. Can also have different format of output with addition parameters.

git log
git log <number>

Please see the Burmese version here.

--

--