linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
Intro
Lessons
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Chapters
  • How it works
  • Lessons
  • Knowledge base
  • Interview prep
home/git/kb/Everyday workflow/status

kb/workflow ── Everyday workflow ── beginner

git status

Shows the difference between three Git zones: what is modified in the working tree, what is staged in the index, and which branch is active. The safest command in Git: it changes nothing and you can run it as often as you like.

view as markdownaka: git-status

git status is your "where am I" in Git. Without it, work becomes guesswork. Run it before every add and commit, and after switching branches.

What it shows

Several sections, top to bottom:

  1. Current branch and its position relative to the remote: On branch main, Your branch is ahead of 'origin/main' by 2 commits.
  2. Changes to be committed: what is in the index and will go into the next commit (shown in green).
  3. Changes not staged for commit: modified tracked files that are not yet in the index (shown in red).
  4. Untracked files: new files that Git is not tracking (shown in red).

Each section suggests the next command: "use git add to stage", "use git restore to discard".

Short format

The verbose output is useful for beginners. For day-to-day work, -s (short) is faster to read:

bash
git status -s
# M  README.md     ← staged: modified
# MM src/api.ts    ← staged and then modified again
#  M src/index.ts  ← modified, not staged
# ?? newfile.txt   ← untracked
# A  added.ts      ← new, staged
# D  deleted.ts    ← deleted, staged

Two characters: left is the index state, right is the working tree state. Once you know these symbols, you read the output at a glance.

Branch + ahead/behind

git status -sb adds a branch line at the top showing how far you are from the remote:

## main...origin/main [ahead 2, behind 1]

You have 2 local commits not in origin, and origin has 1 commit you do not have. You need to merge or rebase before pushing.

Pitfalls

  • On large repositories status can be slow. If it is lagging, run git update-index --refresh or enable feature.manyFiles or core.fsmonitor in the config.
  • git status does not show the stash. To see what is stashed, run git stash list.
  • If a file is in .gitignore, status is silent about it. To find out why a file is ignored, run git check-ignore -v file.

§ команды

bash
git status

Full human-readable report

bash
git status -s

Short machine-readable format, two columns of symbols

bash
git status -sb

Short format plus the branch line with ahead/behind info

bash
git status --porcelain=v1

Stable format for scripts

§ см. также

  • addgit addMoves file changes from the working tree into the index (staging area). Does not commit anything. It only controls what goes into the next commit.
  • commit-cmdgit commitCaptures what is in the index as a new commit object and moves the current branch to that commit. Without arguments it opens an editor for the message; the most common form uses `-m`.
  • loggit logTraverses the commit graph and prints each commit. By default it starts at HEAD and follows parents. A dozen flags cover 95% of history-browsing scenarios.
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies