Copy-ready Git commands for everyday workflows
All content runs locally in your browser

The Git Cheatsheet is a curated set of commands you can copy and paste for common workflows: configuring Git, cloning a repo, committing, working with branches, syncing with remotes, and safely undoing mistakes.
Quick promise: if you can remember just a few concepts — working tree, staging area, and — Git becomes much less scary.
Who is this for?
Pairs well with other tools
If you’re cleaning up URLs in scripts, try our Slugify String tool. If you’re debugging APIs, the URL Parser and HTTP Status Codes pages are handy companions.
How to interpret results
Safety tip
Before you run any reset command, take 10 seconds to confirm what it will change. A quick mental model is that points to “your current commit”. Many undo commands simply move .
Example 1: Configure Git for the first time
Background: you installed Git (or set up a new laptop) and commits show the wrong author.
Inputs (replace placeholders):
git config --global user.name "Ada Lovelace" git config --global user.email "[email protected]"
Result: new commits will use that identity. You can sanity-check with git config --list.
Example 2: Undo the last commit, keep changes staged
Background: you committed too early, but the commit content is correct — you just want to edit the message or add one more file.
Command:
git reset --soft HEAD~1
Mental model (what changes):
Practical next step: run git commit --amend (or add files, then commit again).
Starting a feature branch
Background: you’re about to make a change and want a clean branch.
Input: branch name feature/login
git switch -c feature/login
Apply it: open a PR from that branch when you’re done.
Syncing your local branch with remote
Background: teammates pushed changes and you want the latest before you continue.
Input: remote is origin
git fetch origin\ngit pull
Apply it: if conflicts appear, resolve them, then re-run git status.
Recovering from an accidental commit
Background: you committed debug logs and want to fix it quickly.
Input: undo 1 commit
git reset --soft HEAD~1
Apply it: remove the logs, then recommit with a clean message.
Parking work temporarily (stash)
Background: you need to quickly switch tasks without committing half-finished work.
Input: message "wip: refactor"
git stash push -m "wip: refactor"
Apply it: come back later with git stash pop.
You’re not sure what changed
Useful when: you edited files and want a quick overview.
git status\ngit diff
Not ideal when: you need a full history view — use git log.
You need to create a clean branch
Useful when: you want to isolate work before opening a PR.
git switch -c [branch]
Not ideal when: you need to keep history linear — consider rebasing, carefully.
You want to undo the last commit
Useful when: the commit is wrong, but you still want the code changes.
git reset --soft HEAD~1
Not ideal when: the commit is already pushed to others — consider revert.
You want to match the remote exactly
Useful when: your local branch is messy and you want a clean reset.
git fetch origin\ngit reset --hard origin/[branch-name]
Not ideal when: you have local work you need — stash or create a backup branch first.
You need to pause work without committing
Useful when: you must switch tasks quickly.
git stash push -m "[message]"
Not ideal when: you want reviewable history — commit to a WIP branch.
You’re about to run a destructive command
Useful when: you want a quick pre-flight check.
git status\ngit log --oneline -5
Not ideal when: you need to recover remote history — use hosting tools (GitHub/GitLab) too.
Avoid common mistakes
A tiny workflow that saves time
Git isn’t “math”, but a clean mental model behaves like a little state machine. Most commands change one or more of these three: the working tree, the index (staging area), and .
The 3-state model
That’s why git reset --soft HEAD~1 is usually the safest “undo last commit” choice when you plan to recommit.
Branch vs remote branch
A local branch is what you work on. A remote-tracking branch (like origin/main) is Git’s view of what the server currently has.
Reset vs revert
Reset rewrites your local history by moving . Revert creates a new commit that undoes a previous commit. If others already pulled your commits, revert is often the safer social choice.
Stash isn’t a backup
Stash is a convenience shelf, not a long-term storage plan. If the work matters, consider committing to a “wip” branch.
Git stores an author identity with each commit. Setting user.name and user.email makes your commits consistent across repositories.
Soft reset mainly moves . Hard reset can overwrite both staged changes and files on disk, which is why it’s risky.
If others might have pulled it, prefer git revert (non-destructive) to avoid breaking their history.
Use a compact graph view: git log --oneline --decorate --graph --all, then copy the commit hash into git show [commit].
Because -a only stages tracked files. New files still need git add.
It’s usually fine for short-term use, but it’s not a substitute for committing. If it’s important, commit it to a branch.
Yes — the Reset button clears copy state and scrolls back to the top.
Limitations / disclaimers
This cheatsheet is a convenience reference, not a full Git tutorial. Destructive commands (especially anything with --hard) can delete local work. If you’re unsure, make a backup branch or consult your team’s workflow.
External references / sources
Use a simple chronometer (stopwatch) to track elapsed time down to milliseconds. Runs locally in your browser.
Normalize email addresses to a standard format for easier comparison. Useful for deduplication and data cleaning. Runs locally in your browser.
Estimate the time needed to consume a total amount at a constant rate, and get an expected end time. Runs locally in your browser.
Parse and decode your JSON Web Token (JWT) and display its content. All computation runs locally in your browser.
Know which file extensions are associated to a MIME type, and which MIME type is associated to a file extension. Includes a full MIME types table.
Generate random Lorem Ipsum placeholder text with customizable paragraphs, sentences, and word counts. Runs locally in your browser.