git status

Estimated reading: 2 minutes 15 views

The git status command shows the current state of the working directory and staging area in a Git repository. It tells you which changes are staged (ready to be committed), which are not, and which files are not being tracked by Git.

What Does git status Do?

  • Shows Staged Changes: Files that have been modified and staged for the next commit.
  • Shows Unstaged Changes: Files that have been modified but are not yet staged for commit.
  • Shows Untracked Files: Files that are not yet being tracked by Git.

Syntax

				
					git status

				
			

Example Output

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

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    modified:   example.txt

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:   anotherfile.txt

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

    newfile.txt

				
			

Why Use git status?

  • Track Your Progress: See which files have been modified, staged, or are untracked.
  • Check Before Committing: Understand what changes will be included in your next commit.

Conclusion

The git status command is a useful way to keep track of your changes and ensure you’re ready to commit. It helps you monitor the state of your files, whether they’re staged, modified, or untracked.

Leave a Comment

Share this Doc

git status

Or copy link

CONTENTS