Git Status
The git status
command displays the current state of the working directory and the staging area.
It allows viewing which changes have been staged, which haven't, and which files are tracked or untracked by git.
It's a good practice to run the git status
command whenever you are in doubt. It will provide useful information
depending on your situation.
The git status
command only displays information. It will not change the local repository or do any
modification on commit history. So it's safe to run the git status command any time you want to check your working directory's current state.
What git status tells
The git status command displays different information about the current state. We can summarize what the git status command tells on the following points:
If there are any modified files in the working directory, or the staging area that have not been committed yet.
If the modified files are staged or not.
If the new or modified files are tracked or not by git.
When the local branch is linked to a remote branch, the git status command will tell if the local branch is behind or ahead by any commits.
Where HEAD is pointing, whether it is a commit or a branch.
When merge conflicts occur, the git status command will tell which files are the source of the conflict.
How to use git status
The git status command is a simple, straightforward command. It simply shows the current state of the working directory and the staging area.
The git status message can contain helpful directives for stage/unstage, commit/undo commit files.
Most often, the git status command is used with the default form that shows a good base of information as follows:
$ git status
The git status command offers a -s
flag to output information in a short format. We can see it as follows:
$ git status -s
And also, the git command provides another option -v
for displaying more details. The command will run as follows:
$ git status -v