Master Git & GitHub From Scratch

Clear, practical, and structured lessons designed to take you from Git fundamentals to real-world GitHub collaboration.

Checking Status

what is the purpos of git status?

The primary purpose of git status is to give you a clear, real-time snapshot of the current state of your working directory and staging area. It acts as a safety checkpoint before you save or share your code changes.

Specifically, it answersfour critical questionswhile you are developing:

1. What branch am I currently on?

It prevents you from accidentally committing code to the wrong branch (e.g., making changes directly on main or master instead of a feature branch).

2. Is my local branch synchronized with the remote server?

It checks your local repository against your remote repository (like GitHub or GitLab) and tells you if you are up-to-date, ahead (unpushed commits), or behind (missing remote updates).

3. Which files have been modified but not staged yet?

It highlights files you have edited, created, or deleted since your last commit.

Red text / Unstaged:Changes exist on your computer, but Git is not prepared to save them yet.

4. Which files are ready to be committed?

It shows you exactly what will be included in your next version snapshot.

Green text / Staged:Changes have been added using git add and are locked in, waiting for a git commit command.

Terminal — git status
Bash

$ git status

On branch main

Your branch is up to date with 'origin/main'.

Changes not staged for commit:

(use "git add <file>..." to update what will be committed)

(use "git restore <file>..." to discard changes in working directory)

modified: Index.cshtml

Untracked files:

(use "git add <file>..." to include in what will be committed)

About.cshtml

no changes added to commit (use "git add" and/or "git commit -a")

Git Status Command Reference
Command Description & Use Case
git status Displays paths that have differences between the index file and the current HEAD commit, paths that have differences between the working tree and the index file, and paths in the working tree that are not tracked.
git status -s Gives a short-format, highly compact output summary of file states (e.g., M for modified, ?? for untracked). Ideal for large file modifications.
git status -b Shows the current branch and tracking information even when using the short-format output summary.