Git Cheatsheet

Text

Quick reference for common git commands like init, commit, branch, merge and rebase for daily version control workflow and troubleshooting lookups.

33 commands
Setup
4
git initInitialize repo
git clone <url>Clone repository
git config --global user.name "Name"Set user.name
git config --global user.email "e@x.com"Set user.email
Status / Inspect
5
git statusShow status
git log --oneline --graphPretty history
git diffUnstaged changes
git diff --stagedStaged changes
git show <commit>Show commit
Staging / Commit
6
git add <path>Stage file
git add -pStage by hunk
git commit -m "msg"Commit staged
git commit --amendEdit last commit
git reset <file>Unstage
git restore <file>Discard local changes
Branches
7
git branchList branches
git switch <name>Switch branch
git switch -c <name>Create & switch branch
git merge <branch>Merge into current
git rebase <branch>Rebase onto target
git branch -d <name>Delete branch (safe)
git branch -D <name>Force-delete branch
Remote
5
git remote -vList remotes
git remote add origin <url>Add a remote
git push -u origin mainPush & track
git pull --rebasePull with rebase
git fetch --all --pruneFetch all remotes
Undo / Fix
6
git reset --soft HEAD~1Undo last (keep changes)
git reset --hard HEAD~1Undo last commit (keep changes)
git revert <commit>Safe revert
git stashStash uncommitted
git stash popPop stash
git 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

  1. Open the Git Cheatsheet tool page
  2. Enter or paste your data into the input area
  3. 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.

Advertisement

Comments

No comments yet. Be the first!

Comments are stored locally in your browser. Configure Giscus for cloud-based comments.