LinuxCommandLibrary

git-status

Show the status of the working directory

TLDR

Show changed files which are not yet added for commit

$ git status
copy

Give output in short format
$ git status [[-s|--short]]
copy

Show verbose information on changes in both the staging area and working directory
$ git status [[-vv|--verbose --verbose]]
copy

Show the branch and tracking info
$ git status [[-b|--branch]]
copy

Show output in short format along with branch info
$ git status [[-sb|--short --branch]]
copy

Show the number of entries currently stashed away
$ git status --show-stash
copy

Don't show untracked files in the output
$ git status [[-uno|--untracked-files=no]]
copy

SYNOPSIS

git status [options]

PARAMETERS

--short, -s
    Gives the output in a concise, one-line-per-file format, useful for scripting.

--branch, -b
    Displays information about the current branch and its upstream tracking branch, including ahead/behind counts.

--porcelain[=version]
    Provides machine-readable output format, designed to be stable and parsable by scripts. Default version is '1', '2' is available for more structured output.

--long
    The default output format, showing detailed information in multiple sections.

--untracked-files[=mode]
    Shows untracked files. mode can be no (do not show), normal (show just filename), or all (show contents of untracked directories).

--ignored
    Shows ignored files in addition to untracked files. Requires --untracked-files=all.

--no-ahead-behind
    Suppresses the display of the ahead/behind count for the current branch relative to its upstream.

--column[=options]
    Displays untracked files and ignored files in columns, making the output more readable. options can specify layout.

--show-stash
    Shows the number of currently stashed entries.

DESCRIPTION

The git status command displays the state of the working tree and the staging area (index) relative to the last commit. It's a fundamental command for understanding the current state of your Git repository.

It provides critical information, categorizing files into three main groups:
1. Changes to be committed: Files that have been staged (added to the index) and are ready to be committed.
2. Changes not staged for commit: Modified files in the working directory that have not yet been added to the staging area.
3. Untracked files: New files in the working directory that are not tracked by Git and have not been added to the staging area.

git status helps developers monitor their progress, identify uncommitted changes, and decide which files need to be staged or ignored before making a commit. It's an essential tool in the daily Git workflow.

CAVEATS

git status only shows changes relative to the HEAD commit. It does not display changes that are already committed.
By default, it does not show individual files within untracked directories unless --untracked-files=all is used. Ignored files are also hidden by default.

SHORT OUTPUT FORMAT (`-S`)

When using the --short or -s option, the output is presented as a list of paths, each prefixed by two characters representing the status. The first character indicates the status of the index (staging area) relative to the HEAD commit, and the second character indicates the status of the working tree relative to the index.

Common status codes include:
M: Modified
A: Added
D: Deleted
R: Renamed
C: Copied
U: Unmerged
?: Untracked
!: Ignored

For example, MM means a file modified in the index and also modified in the working tree. M (space followed by M) means a file modified in the working tree but not staged. M (M followed by space) means a file modified and staged but not committed yet.

HISTORY

git status has been a core and indispensable command since the early days of Git's development. It provides the essential overview required for Git's unique staging area workflow. While its core functionality remains consistent, its output formats have evolved over time to improve human readability (e.g., color, detailed long format) and to support robust scripting (e.g., --porcelain format).

SEE ALSO

git add(1), git commit(1), git diff(1), git log(1), git clean(1)

Copied to clipboard