When to use git
Use git to inspect repository state before changing a deployment checkout. Distinguish uncommitted working-tree changes from committed history, and avoid resetting files simply to make a diagnostic output look clean.
Syntax
git [PARAMETERS] COMMANDSquare brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Check working copy
git status --shortA compact summary shows tracked changes and untracked paths.
View changes
git diffUnstaged tracked-file changes are displayed; this does not include every possible repository change.
View brief history
git log --oneline -n 10Recent commits are summarized without modifying the checkout.
Notes and limitations
- git diff omits new untracked files. Also check git status.
- reset --hard, clean and force pushes can destroy or overwrite work. Check for secrets before committing.
Common questions and troubleshooting
Why is a staged change absent from git diff?
The default diff compares the working tree with the index. Inspect the staged comparison separately and use status to understand both states.
Why should I not reset an unfamiliar checkout?
It can discard someone else's uncommitted work. Inspect and preserve changes before choosing any destructive cleanup or deployment operation.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man git.