Git Status

The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven’t, and which files aren’t being tracked by Git. Status output does not show you any information regarding the committed project history. For this, you need to use git log.


git status

List which files are staged, unstaged, and untracked.


The git status command is a relatively straightforward command. It simply shows you what’s been going on with git add and git commit. Status messages also include relevant instructions for staging/unstaging files. Sample output showing the three main categories of a git status call is included below:

# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
# Untracked files:
# (use "git add <file>..." to include in what will be committed)

Ignoring Files

Untracked files typically fall into two categories. They’re either files that have just been added to the project and haven’t been committed yet, or they’re compiled binaries like .pyc, .obj, .exe, etc. While it’s definitely beneficial to include the former in the git status output, the latter can make it hard to see what’s actually going on in your repository.

For this reason, Git lets you completely ignore files by placing paths in a special file called .gitignore. Any files that you’d like to ignore should be included on a separate line, and the * symbol can be used as a wildcard. For example, adding the following to a .gitignore file in your project root will prevent compiled Python modules from appearing in git status:



It’s good practice to check the state of your repository before committing changes so that you don’t accidentally commit something you don’t mean to. This example displays the repository status before and after staging and committing a snapshot:

# Edit
git status
# is listed under "Changes not staged for commit"
git add
git status
# is listed under "Changes to be committed"
git commit
git status
# nothing to commit (working directory clean)

The first status output will show the file as unstaged. The git add action will be reflected in the second git status, and the final status output will tell you that there is nothing to commit—the working directory matches the most recent commit. Some Git commands (e.g., git merge) require the working directory to be clean so that you don’t accidentally overwrite changes.

Add Comment

Required fields are marked *. Your email address will not be published.