Skip to content
Aback Tools Logo

Git Command Cheat Sheet

Browse 40+ Git commands organized across 10 categories — Setup & Config, Staging, Branching, Sharing, Inspection, Undoing Changes, Stashing, Rewriting History, and Advanced. Search by command name, description, flag, or example. Click any command to copy it to your clipboard instantly. No signup required.

Git Command Cheat Sheet

Browse 44 Git commands organized by category. Search by command name, description, flags, or examples. Click any command or example to copy it to your clipboard. Expand any card to see available flags.

Showing all 44 Git commandsClick any command to copy

Setup & Config

5 commands
git config --global user.name "[name]"

Set the name that will be attached to your commits and tags.

Example:git config --global user.name "Jane Doe"
git config --global user.email "[email]"

Set the email address that will be attached to your commits and tags.

Example:git config --global user.email "jane@example.com"
git config --global core.editor "[editor]"

Set the default text editor for commit messages.

Example:git config --global core.editor "code --wait"
git config --list

List all Git configuration settings currently in effect.

Example:git config --list
git config --global alias.[alias] "[command]"

Create a shortcut alias for a Git command.

Example:git config --global alias.st status

Getting Started

2 commands
git init

Initialize a new local Git repository in the current directory.

Example:git init
git clone [url]

Clone a remote repository into a new local directory.

Example:git clone https://github.com/user/repo.git

Staging & Snapshots

6 commands
git status

Show the working tree status — staged, unstaged, and untracked files.

Example:git status
git add [file]

Stage a file or directory for the next commit.

Example:git add src/index.ts
git commit -m "[message]"

Record staged changes to the repository with a commit message.

Example:git commit -m "feat: add user authentication"
git diff

Show unstaged changes between your working directory and the index.

Example:git diff
git rm [file]

Remove a file from the working tree and stage the deletion.

Example:git rm old-file.txt
git mv [old] [new]

Move or rename a file and stage the change.

Example:git mv old-name.ts new-name.ts

Branching & Merging

6 commands
git branch

List, create, or delete branches.

Example:git branch feature/login
git checkout [branch]

Switch to an existing branch or restore working tree files.

Example:git checkout main
git switch [branch]

Switch to a branch (modern replacement for git checkout for branch switching).

Example:git switch feature/login
git merge [branch]

Merge the specified branch into the current branch.

Example:git merge feature/login
git rebase [branch]

Reapply commits on top of another base branch.

Example:git rebase main
git cherry-pick [commit]

Apply the changes from a specific commit onto the current branch.

Example:git cherry-pick a1b2c3d

Sharing & Updating

4 commands
git remote add [name] [url]

Add a new remote repository connection.

Example:git remote add origin https://github.com/user/repo.git
git fetch [remote]

Download objects and refs from a remote without merging.

Example:git fetch origin
git pull [remote] [branch]

Fetch from a remote and integrate (merge or rebase) into the current branch.

Example:git pull origin main
git push [remote] [branch]

Upload local branch commits to the remote repository.

Example:git push origin main

Inspection & Comparison

4 commands
git log

Show the commit history for the current branch.

Example:git log --oneline --graph --all
git show [commit]

Show information about a commit, tag, or tree object.

Example:git show a1b2c3d
git blame [file]

Show what revision and author last modified each line of a file.

Example:git blame src/index.ts
git tag [name]

Create, list, or delete tags.

Example:git tag v1.0.0

Undoing Changes

4 commands
git restore [file]

Discard changes in the working directory (modern replacement for checkout --).

Example:git restore src/index.ts
git revert [commit]

Create a new commit that undoes the changes from a previous commit.

Example:git revert a1b2c3d
git reset [commit]

Reset the current HEAD to a specified state.

Example:git reset --soft HEAD~1
git clean

Remove untracked files from the working directory.

Example:git clean -fd

Stashing

5 commands
git stash

Temporarily save uncommitted changes to a stash stack.

Example:git stash
git stash pop

Apply the most recent stash and remove it from the stash stack.

Example:git stash pop
git stash list

List all stashed changesets.

Example:git stash list
git stash apply [stash]

Apply a stash without removing it from the stash stack.

Example:git stash apply stash@{2}
git stash drop [stash]

Remove a single stash entry from the stash stack.

Example:git stash drop stash@{0}

Rewriting History

3 commands
git commit --amend

Modify the most recent commit — change message or add staged changes.

Example:git commit --amend -m "fix: corrected typo in auth module"
git rebase -i [base]

Interactively rebase — reorder, squash, edit, or drop commits.

Example:git rebase -i HEAD~3
git reflog

Show a log of all HEAD movements — useful for recovering lost commits.

Example:git reflog

Advanced

5 commands
git bisect start

Use binary search to find the commit that introduced a bug.

Example:git bisect start git bisect bad git bisect good v1.0
git submodule add [url]

Add a Git repository as a submodule inside another repository.

Example:git submodule add https://github.com/user/lib.git libs/lib
git worktree add [path] [branch]

Check out a branch into a new working directory without cloning.

Example:git worktree add ../hotfix hotfix/urgent
git archive [branch]

Create a tar or zip archive of a tree from a branch or commit.

Example:git archive --format=zip HEAD > release.zip
git shortlog

Summarize git log output grouped by author.

Example:git shortlog -sn

Why Use Our Git Command Cheat Sheet?

Fast, searchable, and comprehensive Git command reference

Instant Git Command Search

Find any Git command instantly by searching command names, descriptions, flags, or examples. Our git command cheat sheet searches across all 40+ commands and their flags in milliseconds — no page reloads, no waiting.

Secure Git Cheat Sheet Online

Our git command cheat sheet runs entirely in your browser with no server requests. Your searches and interactions never leave your device, ensuring complete privacy when you use our git cheat sheet online.

Git Cheat Sheet — No Installation

Use our git command cheat sheet directly in any browser with no downloads, plugins, or account required. Look up git commands from any device — desktop, tablet, or mobile — completely free.

Commands, Flags, and Examples

Every entry in our git command cheat sheet includes a description, a real-world example, and expandable flags with explanations. Click any command or example to copy it to your clipboard instantly.

Common Use Cases for Git Command Cheat Sheet

Practical applications for our interactive Git command reference

Learning Git for the First Time

Use our git command cheat sheet to learn the most important git commands in context. Each command includes a plain-English description and a real example, making it easy to understand what each git command does before running it.

Recovering from Mistakes

Search our git cheat sheet for "undo", "revert", or "reset" to quickly find the right command for your situation. The Undoing Changes category covers git restore, git revert, git reset, and git clean with flag explanations.

Code Review and Collaboration

Look up git commands for branching, merging, and rebasing workflows. Our git command cheat sheet covers git branch, git merge, git rebase, and git cherry-pick with all their important flags.

CI/CD and Automation Scripts

Find the exact git command syntax for your automation scripts. Search for flags like "--no-ff", "--force-with-lease", or "--depth" to get the precise command format needed for your pipeline.

Debugging and Inspection

Use the Inspection & Comparison category to find git log, git blame, git show, and git diff commands with their most useful flags. Copy the exact command you need for investigating commit history or file changes.

Advanced Git Workflows

Explore the Advanced category for git bisect, git submodule, git worktree, and git archive commands. Our git cheat sheet covers these less-common but powerful commands with examples and flag explanations.

Understanding Git Commands

Core Git concepts and how the most important commands work

What is Git?

Git is a distributed version control system that tracks changes in source code during software development. Created by Linus Torvalds in 2005, Git allows multiple developers to work on the same codebase simultaneously, maintain a complete history of every change, and branch off to experiment without affecting the main codebase. Our git command cheat sheet covers the essential git commands across 10 categories — from initial setup and staging to advanced workflows like bisect and worktrees.

How Our Git Command Cheat Sheet Works

  1. Search or Browse: Type any keyword into the search box to instantly filter commands by name, description, flags, or examples. Or use the category pills to browse commands by workflow area — Staging, Branching, Undoing Changes, and more.
  2. Read and Expand:Each card shows the command, a plain-English description, and a real-world example. Click “Show flags” to expand the available options for that command with explanations of each flag.
  3. Copy and Use: Click the copy icon next to any command or example to copy it to your clipboard instantly. All processing runs locally in your browser — no data is sent to any server.

Git Command Categories

  • Setup & Config: Configure your identity, editor, and aliases with git config — these settings apply globally to all repositories on your machine.
  • Staging & Snapshots: The core workflow — use git add, git commit, and git diff to stage and record changes to your repository.
  • Branching & Merging: Use git branch, git switch, git merge, and git rebase to manage parallel lines of development and integrate changes.
  • Undoing Changes: Use git restore, git revert, and git reset to undo changes — each with different levels of permanence and safety.

git reset vs git revert vs git restore

These three commands are often confused. git restore discards uncommitted changes in your working directory or unstages files — it only affects your local working tree and is the safest option. git revert creates a new commit that undoes a previous commit — it is safe to use on shared branches because it preserves history. git reset moves the HEAD pointer and optionally modifies the index and working tree — use --soft to keep changes staged, --mixed to unstage them, or --hard to discard them entirely. Never use git reset --hard on commits that have already been pushed to a shared remote.

Frequently Asked Questions About Git Command Cheat Sheet

Common questions about Git commands, workflows, and version control

A git command cheat sheet is a quick reference guide listing the most important git commands with descriptions, flags, and examples. Our interactive git command cheat sheet lets you search across all commands and copy any command to your clipboard instantly — all running locally in your browser.

git fetch downloads changes from the remote repository but does not integrate them into your working branch — it updates your remote-tracking branches only. git pull is essentially git fetch followed by git merge (or git rebase with --rebase). Use git fetch when you want to review changes before integrating them, and git pull when you want to update your branch immediately.

git merge integrates changes from one branch into another by creating a new merge commit, preserving the full history of both branches. git rebase replays your commits on top of another branch, creating a linear history without a merge commit. Use merge for shared branches to preserve history, and rebase for local feature branches to keep a clean linear history before merging.

Use git reset --soft HEAD~1 to undo the last commit while keeping all changes staged. Use git reset --mixed HEAD~1 (the default) to undo the commit and unstage the changes, keeping them in your working directory. Use git reset --hard HEAD~1 only if you want to permanently discard the changes — this cannot be undone unless you have the commit hash in your reflog.

git stash temporarily saves your uncommitted changes (both staged and unstaged) to a stash stack, giving you a clean working directory. This is useful when you need to switch branches without committing incomplete work. Use git stash pop to restore the most recent stash, or git stash apply stash@{n} to apply a specific stash without removing it from the stack.

Yes. Our git command cheat sheet runs entirely in your browser — all 40+ commands are loaded locally with no server requests. Your searches and interactions never leave your device.

Yes! Our git command cheat sheet is 100% free with no signup, no account, no usage limits, and no advertisements. Use it as many times as you need.

git rebase -i (interactive rebase) lets you rewrite your commit history before sharing it. You can squash multiple commits into one, reorder commits, edit commit messages, or drop commits entirely. It is most useful for cleaning up a messy feature branch before merging it into main. Never use interactive rebase on commits that have already been pushed to a shared remote branch.

git switch was introduced in Git 2.23 as a more focused replacement for the branch-switching functionality of git checkout. git checkout does many things — it switches branches, restores files, and checks out commits. git switch only switches branches, making its intent clearer. git restore was introduced at the same time to handle the file-restoration use case. Both git switch and git restore are now the recommended commands for their respective tasks.