Git Status
The most straightforward use of git status
involves simply typing
the command in your terminal or command prompt within a Git repository. This
provides a high-level overview of the repository's status, highlighting
untracked files, changes not staged for commit, and changes to be committed.
bashgit status
1. Verbose Mode:
The verbose mode (-v
or --verbose
) provides a more
detailed output, including information about the branch, tracking branch, and
remote repository status.
bashgit status -v
2. Short Format:
The short format (-s
or --short
) provides a concise,
machine-readable summary of the status. It's particularly useful for scripting
or automation.
bashgit status -s
3. Ignoring Untracked Files:
Sometimes, you might want to ignore untracked files in the
git status
output, especially if there are many autogenerated
files. You can achieve this by using the -u
or
--untracked-files
option followed by a mode:
no
: Shows no untracked files.normal
(default): Shows untracked files and directories.all
: Also shows individual files in untracked directories.
bashgit status -u no
4. Displaying Branch Ahead, Behind, or Diverged Information:
To see information about how your local branch relates to its remote counterpart,
you can use the -sb
option.
bashgit status -sb
5. Short and Porcelain Formats:
For a more script-friendly output, you can use the --porcelain
option in combination with the short format (-s
).
bashgit status --porcelain -s
6. Ignoring Changes in Submodules:
If your repository includes submodules and you want to ignore changes in them,
you can use the --ignore-submodules
option.
bashgit status --ignore-submodules
7. Showing Renamed Files:
By default, git status
doesn't explicitly indicate renamed files. To
include them in the output, use the -M
option.
bashgit status -M
8. Detailed Path-specific Status:
You can check the status of a specific path or file by specifying it after the
git status
command.
bashgit status path/to/your/file
9. Using Aliases:
To make your Git commands more convenient, you can create aliases. For example,
you can create an alias like git s
for git status
.
bashgit config --global alias.s "status"
git s