Skip to content

Git Cheat Sheet

Search twelve source-checked Git commands by workflow or purpose, copy a safe template, and review the placeholder and history warnings.

Privacy: your files never leave your device. All processing happens locally in your browser.

How to use

  1. 1.Search by command, category, or task.
  2. 2.Read the description and replace every angle-bracket placeholder.
  3. 3.Copy the command only after checking repository path, status, branch, and remotes.
  4. 4.Inspect the resulting status, diff, commit, or remote state after execution.

About Git Cheat Sheet

Git Cheat Sheet is a focused reference for twelve everyday commands used to start, inspect, record, branch, and share repository work. Search by category, command, or purpose, then copy the displayed template. The list includes init, clone, short status, unstaged diff, compact decorated log, add, commit, current branch, switch, switch-and-create, fetch with prune, and push with upstream. It intentionally favors explicit modern commands and inspect-first habits over a large catalog of aliases or destructive recovery recipes.

Angle-bracket values are placeholders. Replace <url>, <path>, <message>, and <branch> with values appropriate to the repository and shell; do not type the angle brackets literally. Quote paths or messages when they contain spaces or shell-sensitive characters. A copied command is not automatically safe merely because its syntax is valid. Confirm the working directory, current branch, configured remotes, staged diff, and repository instructions before execution. Team workflows may require signed commits, protected branches, pull requests, or different remote names.

Inspection commands should come before mutation. git status --short summarizes tracked, staged, modified, deleted, and untracked paths. git diff shows unstaged changes, while staged changes require git diff --cached. The compact log example shows ten commits and decorations, but deeper history or a path-limited log may be needed for diagnosis. Output describes repository state at a moment in time; another process, editor, hook, or collaborator can change files or references afterward. Recheck immediately before committing or pushing.

Staging with git add <path> is deliberately narrower than staging the entire tree. Review exactly what entered the index, especially in a shared checkout with generated files, credentials, databases, or unrelated user work. A commit records staged content, not every visible change. Write a message that explains the intent and keep logically separate work in separate commits. Hooks can modify or reject a commit, so inspect the final commit after it succeeds rather than assuming the staged snapshot remained unchanged.

Branch and remote operations affect collaboration. git switch -c creates a local branch; git push -u origin <branch> publishes it and records the upstream. git fetch --prune downloads references and removes stale remote-tracking names without merging into the current branch, but pruning can make deleted remote branches disappear from the local tracking view. Confirm the remote URL and access policy. This sheet intentionally omits force push, hard reset, clean, rebase, and history rewriting because those require stronger context and recovery planning.

The reference is local and read-only until you choose to copy text. It never runs Git, opens a repository, uploads data, or stores commands, and it requires no login or dependency. The twelve entries are checked for unique IDs and command templates against upstream documentation and an independent tutorial source. Git versions and organizational policy can differ, so use git help <command>, project documentation, and a recoverable backup or branch before unfamiliar changes. Never paste secrets into commit messages or remote URLs. When automation invokes Git, pin the working directory, handle exit codes, and capture enough non-sensitive output to diagnose partial failure without exposing credentials.

Methodology & sources

Stores twelve source-checked Git command templates with unique IDs and command strings, searches normalized category/command/description text, and copies exactly one displayed template without accessing or modifying a repository.

Frequently asked questions

Should I type angle brackets around placeholders?
No. Replace the entire placeholder, including brackets, and quote shell-sensitive values when necessary.
Why are reset --hard and force push omitted?
They can discard or rewrite work and require repository-specific recovery planning, so they do not belong in a context-free quick-copy list.
Does this sheet run commands?
No. It only filters and copies text. You remain responsible for the repository, shell, permissions, hooks, and collaboration policy.

Developer Tools guides

View all