git status - ghdrako/doc_snipets GitHub Wiki
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: COPYING
renamed: src/rand.c -> src/random.c
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: Makefile
deleted: README
Untracked files:
(use "git add <file>..." to include in what will be committed)
NEWS
There are up to three sections present in the output:
-
Changes to be committed: This section is about the staged changes that would be committed with
git commit
(without the-a/--all
option). It lists files whose snapshot in the staging area is different from the version from the last commit (HEAD). -
Changes not staged for commit: This section lists the files whose working directory contents are different from their snapshots in the staging area. Those changes would not be committed with
git commit
, but would be committed withgit commit -a
as changes in the tracked files. -
Untracked files : This lists the files, unknown to Git, that are not ignored. These files would be added with the bulk add command, git add ., if run in the top directory of the project. You can skip this section with the
--untracked-files=no
(-uno
for short) option.
If the section does not contain any files, it will be not shown. Note also that the file may appear in more than one section. For example, a new file that got added with git add and then modified would appear in both Changes to be committed and Changes not staged for commit.
One does not need to make use of the flexibility that the explicit staging area gives; one can simply use git add just to add new files and git commit –a to create the commit from changes to all tracked files. In this case, you would create a commit from both the Changes to be committed and Changes not staged for commit sections.
Its --porcelain version is suitable for scripting because it is promised to remain stable, while --short is intended for user output, uses color if possible, and could change in the future. For the same set of changes, this output format would look something like the following:
$ git status --short
A COPYING
M Makefile
D README
R src/rand.c -> src/random.c
?? NEWS
In this format, the status of each path is shown using a two-letter status code. The first letter shows the status of the index (the difference between the staging area and the last commit), and the second letter shows the status of the worktree (the difference between the working area and the staging area):
Symbol | Meaning |
---|---|
(a space) | Not updated/unchanged |
M | Modified (updated) |
A | Added |
D | Deleted |
R | Renamed |
C | Copied |
Not all combinations are possible. Status letters A, R, and C are possible only in the first column, for the status of the index. |
A special case, ??
, is used for the unknown (untracked) files, and !!
for ignored files (when using git status --short --ignored).