Cheatsheets

Git Cheatsheet

Use this Git cheatsheet when you need the right command quickly: status checks, staging, commits, branches, remotes, safe undo workflows and everyday version-control examples.

Quick reference

Everyday commands

Check statusgit status

See changed, staged and untracked files.

Stage filesgit add .

Stage all current changes.

Commitgit commit -m "Message"

Save staged changes with a short message.

View historygit log --oneline --graph

Compact branch history.

Branches and remotes

Create branchgit switch -c feature-name
Switch branchgit switch main
Pull latestgit pull
Push branchgit push -u origin feature-name

Undo safely

Unstage filegit restore --staged file.ts
Discard file changesgit restore file.ts
Amend commitgit commit --amend
Revert commitgit revert <commit>

Inspect and compare

Working diffgit diff
Staged diffgit diff --staged
Show commitgit show <commit>
Find branchesgit branch --all

Stash and recovery

Stash tracked workgit stash push -m "context"
List stashesgit stash list
Apply safelygit stash apply stash@{0}
Recover referencegit reflog

Find recent HEAD movements before recovery.

Examples

CodeStart a feature branch
git switch main
git pull
git switch -c improve-header
CodeCommit a focused change
git status
git add src/components/Header.tsx
git commit -m "Improve header navigation"
CodeReview before pushing
git status
git diff --staged
git log --oneline origin/main..HEAD

Git FAQ

What is included in the Git cheatsheet?

Git Cheatsheet includes quick reference sections, practical examples, common mistakes, tips and links to related DevKitYard tools.

Is the Git cheatsheet interactive?

This cheatsheet is a static quick reference focused on concise commands, syntax and examples.

When should I use this Git reference?

Use it when you need to recall syntax, compare common patterns or avoid mistakes without opening a long tutorial.

What should I use after reading this cheatsheet?

Use related DevKitYard tools such as Gitignore Generator, Text Diff Checker when you need to format, validate, generate or inspect real output.