Check the status of your local repository

Join me as I explain the Git Status command and how you can use it to check the status of your local repository and what changes or not are waiting to be staged or committed.

Check the status of your local repository
Check the status of your local repository

If you are working with source control repositories in GitHub or Azure DevOps, or somewhere similar you may want to check the status of your local repository, is there anything still to be committed upstream or is there any changes that haven't been tracked before you start working with the repository again.

There is a Git command that can help with that.

Git Status

Git status is a command that can be used to display the differences between the index file of your repository and the working directory.   Git status can show you the following:  

  1. There is no commit history
  2. There are untracked files
  3. There are changes to be committed
  4. The working tree is clean
  5. Files have been modified
  6. Files have been deleted

How to use

So how do you use this and what does it look like.

If you pull up your terminal tool of choice, mine is Windows Terminal.  When I am in the folder of one of my GitHub repositories I can run the git status command and get an overview of what's happening with my repository.

Git status
Git status

As you can see from the screenshot I have some new files in my local repository that are not yet committed.  Git status tells me exactly what the files are and where they are.

If I run a git commit to the repository and then run a git status you can see from the screenshot how things have now changed.

Git status after commit
Git status after commit

Making changes and new files

If I make changes to a file and add new files what will git status show me?

Git Status
Git Status

I get information about changes that have not been staged or committed or untracked files.

Git Status Shortened

By default when you run git status you get a verbose output, but you can get a shortened version if you prefer that.

git status -s

By adding the -s switch you get a much shorted output.  If I run it on the repository with the changed file and new file I get a much different output than with the default command.

Git Status Short
Git Status Short

I get an M next to the newfile.md showing me it's been modified but not staged or committed.  I also get question marks next to the file that is untracked at the moment.

Why use Git status?

So really why should you use Git status?  You can use it to check what files have changed, that you aren't about to commit anything you don't or shouldn't want committed and lastly you want to use it to check your not blindly just committing changes without really understanding what your committing.

Let me know if you have any stories of using Git Status, good or bad. 👍