Open In App

Git Status

Last Updated : 04 Oct, 2025
Comments
Improve
Suggest changes
3 Likes
Like
Report

The git status command is used to display the state of the working directory and the staging area. It shows which changes have been staged, which have not, and which files are not being tracked by Git. This command is important for understanding the current status of your project and for making informed decisions about your next steps.

To use the git status command, navigate to your Git repository in your terminal and type:

git status

This command does not require any arguments, and its output provides a snapshot of your repository’s status.

Creating a project folder and Initializing Git

$ mkdir gfg
$ cd gfg
$ git init

Output:

Git Status when working tree is clean:

$ git status

Output:

Here, the Working tree is clean that's why the output is coming as nothing to commit.

Git Status when a new file is created:

$ touch new.txt
$ git status

Output:

Here, We created a new file that's why it is showing untracked files. We can use the 'git add' command to include this file.

$ git add new.txt
$ git status

Output:

Now, It is showing changes to be committed which means the file is now included and ready to commit. We can commit files using the git commit -m "message" command.

$ git commit -m "first commit"
$ git status

Output:

After committing, the status is now changed to nothing to commit because now the working tree is clean.

Git Status when an existing file is modified:

First, we need to add some content to our new.txt file.

Now execute command i.e.

$ git status

Output:

It is showing modified: new.txt means something is modified in it. Now let's add it and commit it.

$ git add new.txt
$ git commit -m "file modified"
$ git status

Output:

After adding and committing our working tree is cleaned that's why git status is showing 'nothing to commit'.

Git Status when the file is deleted:

$ git rm new.txt
$ git status

Output:

After deleting the file git status command show's the deleted file name and it is also ready to commit it by using the git commit command. So let's commit it and then see the status of the repo.

$ git commit -m "file deleted"
$ git status

Output:

After committing our working tree is cleaned that's why git status is showing 'nothing to commit'.

Suggested Quiz
5 Questions

What does the git status command primarily show?

  • A

    The contents of the .git folder

  • B

    The list of all previous commits

  • C

    The state of the working directory and staging area

  • D

    The remote branches in the repository

Explanation:

git status displays the current condition of your working directory and staging area. It shows:

  • untracked files
  • modified files
  • staged files
  • deleted files
    This helps developers understand what needs to be staged, committed, or ignored.

If git status shows “untracked files,” what does it mean?

  • A

    Git has committed the file automatically

  • B

    The file was deleted from the repository

  • C

    Git is not tracking the file because it has never been staged before

  • D

    The file is staged but not committed

Explanation:

"Untracked files" means Git is not monitoring those files because they have never been added using git add. These files exist in the working directory but are not part of version control yet.

After running git add new.txt, the status shows “changes to be committed.” What does this indicate?

  • A

    The file has already been committed

  • B

    The file is now staged and ready for the next commit

  • C

    The file is untracked

  • D

    The file has been deleted

Explanation:

Once a file appears under “changes to be committed”, it means the file is successfully staged. It will be included in the next commit when you run git commit -m "message".

What will git status display when the working tree is clean?

  • A

    A list of modified files

  • B

    A list of staged files

  • C

    "Working tree clean" or "nothing to commit"

  • D

    The entire commit history

Explanation:

A clean working tree means there are no untracked, modified, or staged files. Git displays messages like:

  • "nothing to commit"
  • "working tree clean"

This indicates the repository is fully up to date.

When a file is deleted using git rm file.txt, what will git status show before committing?

  • A

    The file will disappear completely

  • B

    It will show the file under “untracked files”

  • C

    It will show the file under “changes not staged for commit”

  • D

    It will show the file as “deleted” under “changes to be committed”

Explanation:

After git rm file.txt, Git stages the deletion automatically. Thus, git status shows:

  • deleted: file.txt under “changes to be committed”
    This indicates the deletion will be recorded in the next commit.
Quiz Completed Successfully
Your Score :   2/5
Accuracy :  0%
Login to View Explanation
1/5 1/5 < Previous Next >

Explore