git status

Check which files have changed, what is staged for commit, and the current state of your working directory.

Before you commit, before you switch branches, before you push—you run git status. It's the command you use to get your bearings in Git, showing you which files have changed, what's staged for the next commit, and what's still untracked. Think of it as Git's way of answering "what's going on right now?" It's one of the safest commands you can run because it only reads information, never modifies anything.

When you run git status, you see three categories of files. First, changes staged for commit—these are files you've run git add on and will be included in your next commit. Second, changes not staged for commit—files Git is tracking that you've modified but haven't staged yet. Third, untracked files—new files that Git doesn't know about yet. This breakdown makes it immediately clear what will happen when you commit and what's still waiting for attention.

The output shows your current branch and whether it's ahead, behind, or in sync with the remote. If you see "Your branch is ahead of 'origin/main' by 2 commits," you know you have local commits that haven't been pushed yet. If it says "Your branch is behind," someone else has pushed changes you don't have locally. This context helps you avoid conflicts and understand where your work stands relative to your team's.

Working with Modified Files

When files appear under "Changes not staged for commit," Git tells you exactly what to do with them. It reminds you to use git add to stage them for commit or git restore to discard changes. These hints make status useful not just for information but as a guide for your next step. If you've modified ten files but only meant to change three, status shows you which ones have changed so you can stage selectively.

Red and green coloring (in terminals that support it) provides quick visual feedback. Modified files appear in red, staged files in green. You can scan the output instantly to see what's ready to commit versus what still needs staging. If everything's green and the working tree is clean, you're safe to switch branches or pull updates without worrying about conflicts.

Short Format and Porcelain

For experienced developers who want less verbose output, git status -s provides a compact view. Each file gets a two-letter code: M for modified, A for added, D for deleted, and ?? for untracked. The first letter represents the staging area, the second represents the working directory. So M means modified and staged, M means modified but not staged, and MM means modified, staged, then modified again. Once you learn this format, you can scan status updates much faster.

Scripts and tools use git status --porcelain to get machine-readable output that doesn't change format across Git versions. This stable format makes it reliable for automation, though humans rarely use it directly. If you're writing a script that needs to check repository state, porcelain mode ensures your script won't break when Git's human-readable output format changes.

Pull Request Workflow

In pull request workflows, status becomes your checklist before pushing. You run it before committing to verify you're staging the right files. You run it before switching branches to make sure you won't lose uncommitted work. You run it after pulling changes to see if there are conflicts. It's the command that keeps you oriented as you move through your workflow.

When reviewing a pull request locally, checking out someone else's branch and running git status shows whether the branch is clean or has uncommitted changes. If status shows modified files you didn't change, something's wrong—maybe there's a merge conflict or local configuration differences. A clean status means the branch is exactly as the author pushed it.

Many developers have muscle memory that includes running status constantly. After modifying files, before committing, after switching branches—status becomes a reflex that keeps you aware of your repository's state. It's also forgiving—you can run it as many times as you want without any consequences, making it perfect for checking your work before taking action.

Understanding status output helps you understand Git's three-stage model: working directory (where you edit files), staging area (where you prepare commits), and repository history (where commits are saved). Status shows you the relationship between these stages, making it clear what needs to move where before you can commit or switch branches.