Git Cheatsheet
TextQuick reference for common git commands like init, commit, branch, merge and rebase for daily version control workflow and troubleshooting lookups.
git initInitialize repogit clone <url>Clone repositorygit config --global user.name "Name"Set user.namegit config --global user.email "e@x.com"Set user.emailgit statusShow statusgit log --oneline --graphPretty historygit diffUnstaged changesgit diff --stagedStaged changesgit show <commit>Show commitgit add <path>Stage filegit add -pStage by hunkgit commit -m "msg"Commit stagedgit commit --amendEdit last commitgit reset <file>Unstagegit restore <file>Discard local changesgit branchList branchesgit switch <name>Switch branchgit switch -c <name>Create & switch branchgit merge <branch>Merge into currentgit rebase <branch>Rebase onto targetgit branch -d <name>Delete branch (safe)git branch -D <name>Force-delete branchgit remote -vList remotesgit remote add origin <url>Add a remotegit push -u origin mainPush & trackgit pull --rebasePull with rebasegit fetch --all --pruneFetch all remotesgit reset --soft HEAD~1Undo last (keep changes)git reset --hard HEAD~1Undo last commit (keep changes)git revert <commit>Safe revertgit stashStash uncommittedgit stash popPop stashgit reflogRecovery log (reflog)About Git Cheatsheet
In daily Git use, the flags for rebase, stash, and reset and the steps to recover commits via reflog are hard to remember, and searching mid-task breaks your flow. This tool is a categorized Git command cheat sheet covering high-frequency scenarios — committing, branching, merging, undoing, remote sync, and stashing — each with an explanation and typical usage. It renders locally with the page, no network needed, so you can glance at it beside your terminal. Tip: Bookmark this tool for quick access whenever you need text processing. All processing happens locally in your browser — no data upload, so feel free to paste private content.
How to Use
- Open the Git Cheatsheet tool page
- Enter or paste your data into the input area
- View the real-time results and use the copy button to get the output
Use Cases
- Undo actions — Quickly check the difference between reset, revert, and checkout to safely roll back mistakes.
- Branch management — Reference create, switch, delete, and merge commands to clarify your branching workflow.
- Recover commits — Use reflog-related commands to recover commits lost to a reset or accidental deletion.
- Stash changes — Look up stash save, list, and restore usage to switch tasks without losing your working tree.
- Team standard — Use the cheat sheet as a shared Git reference to reduce mistakes across the team.
- Interactive rebase — Check the squash and reword flags for interactive rebase to clean up commit history.
- Cherry-pick flow — Look up the correct syntax to cherry-pick a range of commits between branches.
FAQ
What is the difference between reset soft, mixed, and hard?
soft moves HEAD but keeps the index and working tree; mixed (default) resets the index but keeps changes; hard discards working-tree changes too, so confirm before using it.
Should I use revert or reset?
For commits already pushed, prefer revert — it adds an inverse commit without rewriting history; reset rewrites history and suits local, unshared commits.
Does rebase lose commits?
A normal rebase does not lose commits but rewrites their hashes; if something goes wrong, use reflog to recover the previous HEAD.
Do these commands work on Windows?
Yes. The commands themselves are cross-platform; differences are mainly in the shell, and they work in Git Bash and PowerShell.
How do I write better commit messages?
The cheat sheet helps with commands; for well-structured commit messages, follow the Conventional Commits style and pair it with our related tools.
Any browser compatibility requirements?
This tool works in all modern browsers (Chrome, Firefox, Edge, Safari). No plugins or extensions required.
Can I use it offline?
After initial load, most features work offline. The core logic runs entirely in your browser with no network dependency.
Comments
Comments are stored locally in your browser. Configure Giscus for cloud-based comments.