Understanding “Git Status”: A Deep Dive for Advanced Developers
Making git status magic with mapaches and Oh My Zsh! plugins
As professional software engineers, we often rely heavily on version control systems for managing changes in our projects.
Git is by far the most popular system today. It helps maintain sanity amidst the chaos of continuous development, version control, bug fixes, and new features. One command, git status -u, stands out as a versatile and often-used command, especially if you’re as forgetful as me and just can’t remember what you modified or added two minutes ago. Today, we’ll deep dive into this all-important command and demystify it once and for all.
The Basics: What Is git status and What Does It Do?
git status -u is a command used to display the state of the Git working directory, what’s called the staging area. It permits you to see which changes have been staged, and which haven't, along with which files aren’t being tracked by Git. Think of it as a mapache 🦝 that prowls through your repo at night, giving you a status report of all the things that have changed.
git status -u
We have to include the -u or --untracked flag. I never skip it, so don’t forget. When you run this command, you will receive an output similar to:
On branch main
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: mapache.txt
Changes not staged for commit:
(use "git add <file>..." to commit)
modified: mapache2.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
mapache3.txtThis feedback tells us exactly what’s going on in our project. The sections are all neatly divided: changes that are ready to be committed, changes not staged for commit, and untracked files. That’s the point of git status -u!
Beyond the Basics: git status Options
Now, for those of you who love to tweak and modify commands, our star git status comes with a variety of options that you can use.
How To Shorten The Git Status Output
The -s or --short option shows the output in a short format: more compact and less verbose. Mapache🦝! Report using the short status:
git status -u -s
Here’s what happens:
M mapache2.txt
?? mapache3.txt
A mapache.txtThe M stands for modified, A for added, and ?? for untracked files. This option is quite handy when you're dealing with a large number of files.
How To Show Ignored Files Using Git Status
Sometimes, you need know which files are being ignored in your Git repo, like when a file doesn’t appear in your commit, and you don’t know why.
You’ll need to add the --ignored flag:
git status -u --ignoredNote that I still included the -u for untracked files, since I always use it with the git status command.
On branch main
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: mapache.txt
Changes not staged for commit:
(use "git add <file>..." to commit)
modified: mapache2.txt
Untracked files:
(use "git add <file>..." to include in what will be committed)
mapache3.txt
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
mapache.logIn this output, our mapache has found an ignored 🦝mapache.log file. This is really useful when you’re trying to debug issues related to .gitignore.
Bringing It All Together: git status in GitHub Desktop
Many developers prefer using graphical user interfaces like GitHub Desktop for Git operations. How does git status -u manifest there?
In GitHub Desktop, the state of your repository is shown automatically without needing to run git status -u. (Ta-da! 🪄)
The GitHub Desktop UI divides changes into Changes and History.
The Changes tab is equivalent to git status, because it visually shows which files are modified, new, or deleted. This part of the screen will also display which changes are staged for the next commit.
A real code mapache 🦝 would likely prefer the command line, but for a human like me, the GUI is so much freaking easier to use. Seriously.
Oh My Zsh Plugins for Automatic Git Status
If you’re using Oh My Zsh!~~~ on MacOS 🤑🫰, I highly recommend the following two Oh My Zsh!~~~ plugins to improve your git status game.
First, we’ll add instant & automatic git status right to your prompt. Oh yeah, that’s what git-prompt does. It’s pretty baller.
Second, we have some actual mapache magic 🦝🧙♂️🪄. What if I told you pressing Enter would automatically run git status -u? Wow!
The magic-enter plugin defaults to git status -u, which makes typing that command as easy as a single keypress from your code terminal.
Conclusion: Git Status Would Like a Word With You
The git status -u command is absolutely one of the most commonly-used tools in your Git toolbox. It allows you to keep track of your Git changes and ensure that your commits are precise, purposeful, semantic, and conventional. It’s like a mapache 🦝 … adorable? Sorry, I think I mixed the metaphor. Code mapache, I need another git status report, STAT!
Ahem. The next time you find yourself lost in the wilderness of your repository, remember your friendly neighborhood code mapache and the power of git status -u. You might just find your way back on track faster than you expected! And, if you liked this one, you’ll love these 2 articles:
Happy coding! 😇





