Git, containers and DevOps

Command git

Work with Git repositories

Linux · Bash examples · commands run on the selected server

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] COMMAND

Square 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

status
Working copy and index status.
diff
Differences between working files, index and commits.
log
Commit history.

Usage examples

Check working copy

git status --short

A compact summary shows tracked changes and untracked paths.

View changes

git diff

Unstaged tracked-file changes are displayed; this does not include every possible repository change.

View brief history

git log --oneline -n 10

Recent 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.