mirror of
https://github.com/mintlify/docs.git
synced 2026-09-14 13:35:46 +08:00
135 lines
2.2 KiB
Plaintext
135 lines
2.2 KiB
Plaintext
---
|
|
title: git status
|
|
description: Show the working tree status
|
|
---
|
|
|
|
Display the state of your working directory and staging area.
|
|
|
|
## Syntax
|
|
|
|
```bash
|
|
git status [options]
|
|
```
|
|
|
|
## Description
|
|
|
|
`git status` shows which files have been modified, which are staged for commit, and which are untracked. This is one of the most frequently used Git commands.
|
|
|
|
## Common usage
|
|
|
|
Check repository status:
|
|
|
|
```bash
|
|
git status
|
|
```
|
|
|
|
## Output explained
|
|
|
|
The output shows three categories of files:
|
|
|
|
### Staged changes
|
|
|
|
Files ready to be committed (added with `git add`):
|
|
|
|
```bash
|
|
Changes to be committed:
|
|
(use "git restore --staged <file>..." to unstage)
|
|
modified: file1.txt
|
|
new file: file2.txt
|
|
```
|
|
|
|
### Unstaged changes
|
|
|
|
Modified files not yet staged:
|
|
|
|
```bash
|
|
Changes not staged for commit:
|
|
(use "git add <file>..." to update what will be committed)
|
|
(use "git restore <file>..." to discard changes)
|
|
modified: file3.txt
|
|
```
|
|
|
|
### Untracked files
|
|
|
|
New files Git isn't tracking yet:
|
|
|
|
```bash
|
|
Untracked files:
|
|
(use "git add <file>..." to include in what will be committed)
|
|
file4.txt
|
|
```
|
|
|
|
## Options
|
|
|
|
<ParamField path="--short" type="flag">
|
|
Show output in short format
|
|
|
|
```bash
|
|
git status --short
|
|
```
|
|
</ParamField>
|
|
|
|
<ParamField path="--branch" type="flag">
|
|
Show branch information even in short format
|
|
</ParamField>
|
|
|
|
<ParamField path="--untracked-files" type="string">
|
|
Control display of untracked files: `no`, `normal`, or `all`
|
|
</ParamField>
|
|
|
|
## Examples
|
|
|
|
### Short status format
|
|
|
|
```bash
|
|
git status --short
|
|
```
|
|
|
|
Output example:
|
|
```
|
|
M modified-file.txt
|
|
A new-file.txt
|
|
?? untracked-file.txt
|
|
```
|
|
|
|
Status codes:
|
|
- `M` = Modified
|
|
- `A` = Added
|
|
- `D` = Deleted
|
|
- `??` = Untracked
|
|
|
|
### Check specific path
|
|
|
|
```bash
|
|
git status docs/
|
|
```
|
|
|
|
## Common workflows
|
|
|
|
### Before committing
|
|
|
|
Always check status before committing:
|
|
|
|
```bash
|
|
git status
|
|
git add .
|
|
git status # Verify what will be committed
|
|
git commit -m "Your message"
|
|
```
|
|
|
|
### After pulling
|
|
|
|
Check for merge conflicts:
|
|
|
|
```bash
|
|
git pull
|
|
git status # Shows conflicts if any
|
|
```
|
|
|
|
## Related commands
|
|
|
|
- [git add](/git/add) - Stage changes
|
|
- [git commit](/git/commit) - Save changes
|
|
- [git diff](/git/diff) - See detailed changes
|
|
- [git log](/git/log) - View commit history
|