git status
git status
: show the status of the working tree.
The git status
command is used to display the current state of your Git repository. It shows which files have been modified, which files are staged for commit, and which files are not being tracked by Git. This command is incredibly useful for understanding what changes you have made since your last commit and what will be included in your next commit if you proceed.
When you run git status
, Git will output information about the current branch, any changes in your working directory, and the status of your staging area. It will also provide helpful suggestions on what to do next, such as using git add
to stage changes or git commit
to commit staged changes.
git status
is a safety net that allows you to double-check your changes before committing them to the repository. By reviewing the output of git status
, you can ensure that you're only committing the changes you intended to and avoid accidentally including unwanted modifications.
Examples
Check the status of your working directory:
git status
Typical output of git status
might look like this:
On branch main
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.html
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: index.html
Untracked files:
(use "git add <file>..." to include in what will be committed)
styles.css