Data report"State of code review 2024" is now liveRead the full report

How to use the `git status` command

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


git status provides detailed information about the working directory (where your code is stored on your local machine) and the index (the staging area where your changes live before being pushed to a remote repository). This command will show you:

  • Which changes have been staged for commit.
  • Which changes are in the working directory but not yet staged for commit.
  • Which files are not being tracked by Git.

When you run git status, Git categorizes files into several sections:

  • Changes to be committed: These are changes that have been added to the staging area with git add and are ready to be committed to your repository.
  • Changes not staged for commit: Changes in files that are tracked by Git but have not been added to the staging area yet.
  • Untracked files: Files in your working directory that are not being tracked by Git. These are usually new files that have been added to your project, or files explicitly ignored by Git specified in the .gitignore file.

To use the git status command, run:

Terminal
git status

After committing all your changes, if there are no untracked or modified files, git status will show:

Terminal
On branch main
Your branch is up to date with 'origin/main'.
nothing to commit, working tree clean

This output indicates that your working directory is clean and there are no changes to commit.

  • On branch main: This indicates that you are currently on the main branch of your repository. In most Git repositories, main (or master in older repositories) serves as the primary branch where the final version of your project lives. This is where all the development branches are eventually merged back into.

  • Your branch is up to date with 'origin/main': This tells you that your local main branch is synchronized with the main branch on the remote repository (usually named origin). "Up to date" means that there are no commits on the remote branch that you don't have locally, and there are no local commits that haven't been pushed to the remote. Essentially, both your local and remote repositories are in the same state in terms of commit history. Due to the way remote branches are tracked, you may need to run git fetch to fetch the most up-to-date changes from the remote repo. There may be remote changes that your local copy of the remote repository doesn't have yet.

  • nothing to commit, working tree clean: This message is quite straightforward. "Nothing to commit" means that there are no changes in your repository that need to be committed. In other words, if you've made changes to your files, they have all been staged (with git add) and committed (with git commit). The "working tree clean" part indicates that there are no modified or untracked files in your current directory. The "working tree" refers to the set of files and directories in your current project that Git is tracking. This message confirms that all changes have been committed to the repository, and there are no pending changes or files that Git is not tracking.

If you have just added a new file to your project and haven't staged it yet:

Terminal
On branch main
Your branch is up to date with 'origin/main'.
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.txt
nothing added to commit but untracked files present (use "git add" to track)

This tells you that newfile.txt is not being tracked by Git. You can stage it for commit with git add newfile.txt.

After modifying a file, if you run git status before staging it:

Terminal
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: modifiedfile.txt

This output shows that modifiedfile.txt has changes that have not been staged for commit.

Once you stage the changes with git add, running git status again will output:

Terminal
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: modifiedfile.txt

Now, modifiedfile.txt is ready to be committed.

For further reading about the git status command see the official Git documentation.

On this page
Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Learn more

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2