Skip to main content

Keeping git status short

Posted in Development and Git

git status is one of the Git commands I use the most. I use it for a quick overview of what I’ve done since that last commit:

  • Which files have changed?
  • Which files have been added?
  • Which files have been removed?
  • Have I staged any of the files already?

But it outputs a lot of info…

➜  tempertemper.net git:(codeblock-layout) ✗ git status
On branch feature/pre-spacing
Your branch is ahead of 'codeblock-layout' by 2 commits.
  (use "git push" to publish your local commits)

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)

        modified:   src/scss/base/typography/_code.scss
        modified:   src/scss/style.scss
        deleted:    src/scss/components/_pre.scss

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

        src/scss/base/_code.scss

no changes added to commit (use "git add" and/or "git commit -a")

In this example, there’re only 4 lines that are of use:

  • the two “modified” files
  • the file I deleted
  • the untracked file

All the rest is noise:

  • I probably don’t care how many commits ahead of the remote branch I am at this point
  • The instructions are repetitive – the git add <file>... command is listed twice
  • The instructions are unnecessary once you know how to stage files, discard changes and commit all changes
  • I know what branch I’m on as it says it right there on the line where I typed the command

Enter --short

Seems like cheating, but just appending the --short flag to your git status command makes things a lot easier to look at. Even better, you can even shorten --short to -s!

git status -s

This outputs just those 4 lines I’m interested in:

➜  tempertemper.net git:(codeblock-layout) ✗ git status -s
 M src/scss/base/typography/_code.scss
 M src/scss/style.scss
 D src/scss/components/_pre.scss
?? src/scss/base/_code.scss

M markers tell me it’s a modified file, D a deleted file, and ?? tells me it’s a newly added file.

If I add a couple of those to the staging area, they look like this:

➜  tempertemper.net git:(codeblock-layout) ✗ git status -s
 M src/scss/base/typography/_code.scss
M  src/scss/style.scss
 D src/scss/components/_pre.scss
A  src/scss/base/_code.scss

The M moves to the left for staged files, to show they’re ready to commit, and the ?? becomes a left-aligned A.

So a simple -s filters out all of the noise, leaving just the information I’m interested in.

Accessibility in your inbox

I send an accessibility-centric newsletter on the last day of every month, containing:

  • A roundup of the articles I’ve posted
  • A hot pick from my archives
  • Some interesting posts from around the web

I don’t collect any data on when, where or if people open the emails I send them. Your email will only be used to send you newsletters and will never be passed on. You can unsubscribe at any time.

More posts

Here are a couple more posts for you to enjoy. If that’s not enough, have a look at the full list.

  1. Avatars and alt text

    I really enjoyed Nicolas Steenhout’s recent article on Alt text for avatars or user photos. But there is a context where I would break his rule…

  2. Upgrading from iPhone 13 mini to 16 Pro

    I get a new phone every 3-ish years, give mine to my wife, and now she gives hers to our daughter. I got a 16 Pro this year! Here’s the skinny.