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

-v, --verbose
    Show more detailed information, including the shortlog of the head commit.

-u[mode], --untracked-files[=mode]
    Show untracked files. Mode can be:
no: Show no untracked files
normal: Show untracked files and directories
all: Also show individual files in untracked directories.

-ignored
    Show ignored files.

-s, --short
    Give the output in the short-format.

-b, --branch
    Show the branch and tracking info even in short-format.

--porcelain[=version]
    Give the output in an easy-to-parse format for scripts. Version can be 1 or 2.

--long
    Show the full status output (default).

--show-stash
    Show the status of the stash as well.

--ahead-behind
    Show how many commits the current branch is ahead or behind the remote tracking branch.

--no-ahead-behind
    Do not show how many commits the current branch is ahead or behind the remote tracking branch.

DESCRIPTION

The git status command displays the state of the working directory and the staging area. It lets you see which changes have been staged, which haven't, and which files aren't being tracked by Git. It is essential for understanding the current state of your repository before committing changes. The output indicates modifications relative to the last commit, identifying tracked files that have been modified but not yet staged (working tree changes) and files that have been staged for the next commit. Untracked files are also listed, providing visibility into files that Git is currently ignoring. The command provides hints on how to proceed, such as using git add to stage changes or git commit to create a new commit with the staged changes. git status can be run from any directory within a Git repository.

CAVEATS

git status only shows the state of the working tree relative to the index (staging area) and the last commit. It doesn't show changes that have only been made on the remote repository. For that, you need to use git fetch and git diff.

EXIT STATUS

The command exits with 0 if no changes need to be committed, 1 otherwise.

HISTORY

git status has been a core part of Git since its early days, providing a crucial tool for developers to understand the state of their repositories. The command's output and options have evolved over time to provide more detailed and actionable information, with additions like the short format for scripting and the ability to show ahead/behind information for branches. Its consistent use and continuous development have solidified its role as one of the most frequently used Git commands.

SEE ALSO

git add(1), git commit(1), git diff(1), git fetch(1), git rm(1), git mv(1)

Copied to clipboard