Git Cheat Sheet
About this tool
About Git Cheat Sheet
Find the git command you need without scrolling through a manual. Commands are grouped by task: setup and config, cloning, staging and committing, branches, merging and rebasing, remotes, history, stash, tags, submodules, worktrees, bisect and clean-up. Each one has a one-line explanation and a copy button, and commands that discard work or rewrite shared history carry a clear warning. The Undo recipes section answers the questions people search for most: how to undo the last commit but keep the changes, fix a commit message, unstage a file, throw away local edits, revert a commit that is already pushed, reset a branch to match the remote, move commits made on the wrong branch, and recover a deleted branch with the reflog. Search matches every word you type across commands and descriptions, so “stash untracked” or “delete remote branch” goes straight to the answer. It works offline once loaded. If the reference doesn't cover your case, ask AI with your own key: you get the commands in order, with warnings on anything destructive.
Built and maintained by Abhi JainUpdated
How to Use the Git Cheat Sheet
- 1
Search
Type what you want to do, for example undo commit or rename branch, in the search box.
- 2
Or browse
Pick a section on the left, such as Undo recipes, Branches or Stash.
- 3
Copy the command
Click the copy icon beside a command and replace placeholders like <branch> before running it.
Git Cheat Sheet: questions and answers
How do I undo the last commit but keep my changes?
Run git reset --soft HEAD~1. The commit disappears and its changes stay staged. If the commit is already pushed to a shared branch, use git revert <commit> instead so you don't rewrite history others have.
What is the difference between git reset and git revert?
git reset moves your branch pointer back, removing commits from the branch (rewriting history). git revert adds a new commit that undoes an earlier one, leaving history intact. Use revert on pushed, shared branches and reset only on local work.
What is the difference between git fetch and git pull?
git fetch downloads new commits from the remote without changing your files. git pull runs a fetch and then merges or rebases those commits into your current branch.
How do I recover a branch I deleted?
Run git reflog, find the last commit the branch pointed to, then git switch -c <branch> <hash>. By default git expires reflog entries for commits no longer on any branch after 30 days, so recover it soon.
Is git push --force safe?
It overwrites the remote branch and can delete teammates' commits. Prefer git push --force-with-lease, which refuses if the remote changed since your last fetch, and never force-push to main or other shared branches.
Can AI help me find a git command?
Yes, optionally. Click Ask AI and describe what you want to do; you get the commands in order with a one-line explanation each, and steps that discard work or rewrite history are flagged using the cheat sheet's own warnings and checks, plus any warning the AI adds. Only your question is sent. It uses the AI provider and key you connect in AI settings (Claude, OpenAI, Gemini, DeepSeek, OpenRouter or a compatible endpoint), and the request goes straight from your browser to that provider; KissThePDF has no server in between.
Related Tools
- .gitignore GeneratorCombine .gitignore templates for languages, frameworks, editors and operating systems, with duplicates removed.
- Conventional Commit GeneratorWrite Conventional Commits messages with type, scope, breaking changes and footers, checked as you type.
- Git Branch Name GeneratorTurn a ticket and title into a clean, valid git branch name, and check any name against git's rules.
- Semver CalculatorCheck npm version ranges, compare and sort versions, and bump major, minor, patch or prerelease.