
- Git - Home
- Git - Version Control
- Git - Basic Concepts
- Git - Command Line
- Git - Installation
- Git - First Time Setup
- Git - Basic Commands
- Git - Getting Help
- Git - Tools
- Git - Cheat Sheet
- Git - Terminology
- Git - Life Cycle
- Git - Get a Repository
- Git - Adding New Files
- Git - Recording Changes
- Git - Viewing Commit History
- Git Branching
- Git - Branches in a Nutshell
- Git - Creating a New Branch
- Git - Switching Branches
- Git - Branching and Merging
- Git - Merge Conflicts
- Git - Managing Branches
- Git - Branching Workflows
- Git - Remote Branches
- Git - Tracking Branches
- Git - Rebasing
- Git - Rebase vs. Merge
- Git - Squash Commits
- Git Operations
- Git - Clone Operation
- Git - Tagging Operation
- Git - Aliases Operation
- Git - Commit Operation
- Git - Stash Operation
- Git - Move Operation
- Git - Rename Operation
- Git - Push Operation
- Git - Pull Operation
- Git - Fork Operation
- Git - Patch Operation
- Git - Diff Operation
- Git - Status Operation
- Git - Log Operation
- Git - Head Operation
- Git - Origin Master
- Git Undoing
- Git - Undoing Changes
- Git - Checkout
- Git - Revert
- Git - Reset
- Git - Restore Operation
- Git - Rm
- Git - Switch Operation
- Git - Cherry-pick
- Git - Amend
- Git on the Server
- Git - Local Protocol
- Git - Smart HTTP Protocol
- Git - Dumb HTTP Protocol
- Git - The SSH Protocol
- Git - The Git Protocol
- Git - Getting Git on a Server
- Git - Setting up the Server
- Git - Daemon
- Git - GitWeb
- Git - GitLab
- Git - Third Party Hosted Options
- Distributed Git
- Git - Distributed Workflows
- Git - Contributing to a Project
- Git - Maintaining a Project
- Customizing Git
- Git - Configuration
- Git - Hooks
- Git - Attributes
- Git - Init
- Git - Commit
Git Status
The git status command displays the status of our working directory.
The output of git status shows where HEAD is at any given time (on a branch or commit). It provides following information:
Untracked files − Shows the files that are not tracked by Git, but are in your working directory.
Changes to be committed − The command git status shows if the changes have been prepped for the upcoming commit by being staged, or added to the index.
Changes not staged for commit − Changes that are made in files that have been modified but not staged yet.
It provides information on how the present local branch relates to its remote equivalent, including how much ahead or far behind.
-
Branch information − The command git status shows the current branch and its tracking state.
Shows conflicts − The command git status shows which files are at conflict when there is a merge conflict.
Variation in paths − Paths that differ between the current HEAD commit and the index file are shown by git status.
It displays paths where there are variations between the index file and the working tree, signifying changes that can be staged using git add.
In addition, the command shows working tree paths that can be added using git add and then staged and committed, as long as they are not ignored by.gitignore or tracked by Git.
Syntax
Following is the syntax of git status command:
git status
Options
The git status command has the following options:
Short Output
Git's -s or --short option changes the output of some commands (like git status) to give a brief, truncated format that highlights important information in a compressed manner.
git status -s git status --short
Branch Information
Git's -b or --branch option improves short format output by adding details about the active branch and its tracking state, adding more context to concise displays.
git status -b git status --branch
Porcelain Output
Git provides commands and outputs that are user-friendly and designed specifically for end-users. The command git status --porcelain gives the output that is concise and easy to parse.
git status --porcelain
Show Stashed Changes
The number of entries that are presently kept in the stash is shown by the Git --show-stash option, which shows how many sets of changes have been temporarily stashed.
git status --show-stash
Long Output
When a command is run with the --long option in Git, it automatically produces an output that is verbose and descriptive.
git status --long
Detailed Output
Git's -v or --verbose option displays both file names that have been edited and are prepared for commit, as well as staged textual changes.
It also shows changes in the working tree that have not yet been staged when used twice (-vv), similar to the output of git diff --cached and git diff.
git status --v git status --verbose
Control Untracked Files Display
Untracked files can be controlled with the --untracked-files option. The different modes that can be used with command are as follows:
no − No untracked files will be displayed.
git status --untracked-files=no
normal − This is the default mode with --untracked-files.
git status --untracked-files=normal
all − Displays all the untracked files.
git status --untracked-files=all
Ignore Submodules
--ignore-submodules[=<when>]
The level of detail that is included can be chosen while checking for changes in submodules.
The choices are as follows:
none− If a submodule contains untracked or updated files, or if its HEAD deviates from the recorded commit of the superproject, it is deemed to be altered.
untracked− If a submodule exclusively contains untracked files, it still checks for updates but ignores them.
dirty− Only displays updates to commits that are registered in the superproject, ignoring any changes made to the submodule's working tree.
all− Keeps submodule summaries in the output hidden and hides all submodule modifications. This is the default value.
git status --ignore-submodules=all
Show Ignored Files
--ignored[=<mode>]
The display of ignored files can be adjusted using the --ignored[=<mode>] option. The default value for the optional mode parameter is traditional.
The modes we can use are as follows:
-
traditional − Unless --untracked-files=all is used, ignored files and directories are shown.
In such case, ignored files inside ignored directories are shown.
no − No files are displayed as ignored.
-
matching − Displays ignored directories and files that fit a pattern of ignores.
A directory is displayed if it matches, but its contents are not if they are disregarded.
The contents of a directory are displayed even if the directory itself is not if all of its contents are disregarded.
git status --ignored
Combination of Options
More than one option can be used at the same time, such that you can customize the output based on your requirements. For example, you can use -s and -b, to get the short status with branch information.
git status -s -b
All in all, git status command helps you understand what changes have been made, what needs to be staged or committed, and the overall state of your repository.