Git Command Cheatsheet

Searchable reference of common git commands with copy buttons.

Works Offline
Privacy First
No Login
No API

Setup

  • git init

    Create a new local repository

  • git clone <url>

    Clone a remote repository

  • git config --global user.name "Name"

    Set your global username

Basics

  • git status

    Show working tree status

  • git add <file>

    Stage changes for commit

  • git add .

    Stage all changes

  • git commit -m "message"

    Commit staged changes

  • git commit --amend

    Amend the previous commit

  • git diff

    Show unstaged changes

  • git diff --staged

    Show staged changes

History

  • git log --oneline --graph

    Compact commit graph history

  • git show <commit>

    Show details of a commit

  • git blame <file>

    Show who last changed each line

Branching

  • git branch

    List local branches

  • git branch <name>

    Create a new branch

  • git checkout -b <name>

    Create and switch to a new branch

  • git switch <name>

    Switch to an existing branch

  • git merge <branch>

    Merge a branch into the current one

  • git rebase <branch>

    Reapply commits on top of another base

  • git rebase -i HEAD~3

    Interactive rebase of last 3 commits

  • git branch -d <name>

    Delete a local branch

Remote

  • git push

    Push commits to the remote

  • git push -u origin <branch>

    Push and set upstream tracking

  • git pull

    Fetch and merge from the remote

  • git fetch

    Download remote refs without merging

  • git remote -v

    List remotes with their URLs

Undo

  • git stash

    Stash uncommitted changes

  • git stash pop

    Reapply the most recent stash

  • git reset --soft HEAD~1

    Undo last commit, keep changes staged

  • git reset --hard HEAD~1

    Undo last commit and discard changes

  • git revert <commit>

    Create a new commit that undoes a commit

  • git checkout -- <file>

    Discard local changes in a file

  • git clean -fd

    Remove untracked files and directories

Tags

  • git tag <name>

    Create a lightweight tag

  • git tag -a <name> -m "msg"

    Create an annotated tag

Advanced

  • git cherry-pick <commit>

    Apply a specific commit onto current branch

  • git bisect start

    Start binary search for a bad commit

  • git submodule update --init

    Initialize and update submodules

  • git reflog

    Show history of HEAD movements

  • git worktree add ../path <branch>

    Check out a branch into a new working directory

Setup
Basics
History
Branching
Remote
Undo
Tags
Advanced

About the Git Command Cheatsheet

Browse and search a categorized list of common git commands — setup, basics, branching, remote, undo, tags, and advanced — with one-click copy for each command.

Examples

Undo last commit

undo

Output

git reset --soft HEAD~1

Related tools

Frequently asked questions

Version 1.0.0 · Updated 2026-08-06 · Runs entirely in your browser