ToolBoxy
💻

Git Cheat Sheet

git · reference · commands

Setup

git config --global user.name "Name"

Set your global username

Copy
git config --global user.email "email"

Set your global email

Copy
git config --global core.editor "code --wait"

Set VS Code as default editor

Copy
git config --list

List all configuration settings

Copy

Initialize

git init

Initialize a new local repository

Copy
git clone <url>

Clone a remote repository

Copy
git clone <url> <dir>

Clone into a specific directory

Copy

Stage & Snapshot

git status

Show working tree status

Copy
git add <file>

Stage a specific file

Copy
git add .

Stage all changes

Copy
git add -p

Interactively stage hunks

Copy
git diff

Show unstaged changes

Copy
git diff --staged

Show staged changes

Copy
git commit -m "message"

Commit staged changes

Copy
git commit -am "message"

Stage tracked files and commit

Copy
git commit --amend

Amend the last commit

Copy

Branch & Merge

git branch

List local branches

Copy
git branch <name>

Create a new branch

Copy
git checkout <branch>

Switch to a branch

Copy
git checkout -b <branch>

Create and switch to new branch

Copy
git switch <branch>

Switch branches (modern syntax)

Copy
git switch -c <branch>

Create and switch (modern)

Copy
git merge <branch>

Merge branch into current

Copy
git branch -d <branch>

Delete a branch

Copy
git branch -D <branch>

Force delete a branch

Copy

Remote

git remote -v

List remotes

Copy
git remote add origin <url>

Add a remote

Copy
git fetch

Fetch all remotes

Copy
git pull

Fetch and merge from remote

Copy
git pull --rebase

Fetch and rebase from remote

Copy
git push origin <branch>

Push branch to remote

Copy
git push -u origin <branch>

Push and set upstream

Copy
git push --force-with-lease

Safe force push

Copy

Undo & Reset

git revert <commit>

Create revert commit

Copy
git reset HEAD <file>

Unstage a file

Copy
git reset --soft HEAD~1

Undo last commit, keep staged

Copy
git reset --hard HEAD~1

Undo last commit, discard changes

Copy
git checkout -- <file>

Discard file changes

Copy
git clean -fd

Remove untracked files/dirs

Copy

Stash

git stash

Stash working directory changes

Copy
git stash list

List all stashes

Copy
git stash pop

Apply latest stash and remove

Copy
git stash apply stash@{n}

Apply specific stash

Copy
git stash drop stash@{n}

Delete a stash

Copy

Log & Inspect

git log --oneline

Compact commit history

Copy
git log --oneline --graph --all

Visual branch graph

Copy
git log --author="Name"

Filter commits by author

Copy
git show <commit>

Show commit details

Copy
git blame <file>

Show who changed each line

Copy
git diff <branch1>..<branch2>

Diff between branches

Copy

How to use

  1. 1

    Search by command or description.

  2. 2

    Browse git commands by section.

  3. 3

    Click an item to copy the command.

FAQ

Is this tool free?

Yes — no sign-up, no installation, completely free to use right away.

What is this tool?

Quick reference for essential Git commands, organized by category with search and click-to-copy support. You can use it for free with no sign-up or installation — just open the page and start right away.