57 commands · one-click copy

Git Command Cheat Sheet

Find the command you need without breaking your flow. Search this practical Git cheat sheet online, copy a command, and get back to shipping.

Instant search Task categories Clear explanations
Skip the guesswork

Copy a complete workflow

Three safe, everyday sequences for when you need more than one command.

01New project

Start a repository

  1. git init
  2. git add .
  3. git commit -m "Initial commit"
03Update safely

Sync your branch

  1. git fetch origin
  2. git rebase origin/main
  3. git push --force-with-lease
Search. Copy. Ship.

Find any Git command fast

Search by command or task, such as undo commit, new branch or see changes.

57 commands ready
01

Everyday essentials

The commands you will reach for most often.

8 commands
git status

Show changed, staged and untracked files.

git add <file>

Stage one file for the next commit.

git add .

Stage all changes in the current directory.

git add -p

Interactively choose which change hunks to stage.

git commit -m "message"

Commit staged changes with a short message.

git pull

Fetch and integrate the current remote branch.

git push

Upload local commits to the tracked remote.

git diff

View changes that have not been staged yet.

02

Setup & start

Configure Git and create or copy a repository.

6 commands
git config --global user.name "Name"

Set the author name used for your commits.

git config --global user.email "you@example.com"

Set the email attached to your commits.

git config --list

List the Git settings currently in effect.

git init

Create a Git repository in the current folder.

git clone <url>

Download a repository into a new local folder.

git clone -b <branch> <url>

Clone a repository and check out one branch.

03

Inspect changes

Understand exactly what changed before you commit.

7 commands
git diff --staged

View changes already staged for the next commit.

git diff -- <file>

Show unstaged changes for one file only.

git show <commit>

Display a commit and the patch it introduced.

git log --oneline

Read a compact list of recent commits.

git log --graph --oneline --all

See branch and merge history as a compact graph.

git blame <file>

Show who last changed each line in a file.

git clean -n

Preview which untracked files Git would remove.

04

Branches & merging

Create, switch, combine and tidy up branches.

8 commands
git branch

List local branches and highlight the current one.

git switch <branch>

Move to an existing local branch.

git switch -c <branch>

Create a new branch and switch to it.

git branch -m <new-name>

Rename the branch you are currently on.

git merge <branch>

Merge another branch into the current branch.

git merge --abort

Stop a conflicted merge and restore the pre-merge state.

git branch -d <branch>

Delete a local branch after it has been merged.

git rebase main

Replay your branch commits on top of local main.

05

Remotes & syncing

Connect local work with a shared repository.

8 commands
git remote -v

List remote names and their fetch and push URLs.

git remote add origin <url>

Connect the repository to a remote named origin.

git fetch origin

Download origin's latest branches and commits.

git pull --rebase

Update your branch and replay local commits on top.

git push -u origin HEAD

Push the current branch and set its upstream.

git push --tags

Upload all local tags to the remote.

git push --force-with-lease

Safely update a remote after rebasing local commits.

git push origin --delete <branch>

Delete a branch from the origin remote.

06

Undo & recover

Back out changes with the least surprising option.

7 commands
Shared branch? Prefer git revert. Reset rewrites local history and can disrupt collaborators if the commits were already pushed.
git restore <file>

Discard unstaged changes in one file.

git restore --staged <file>

Unstage a file while keeping its changes.

git commit --amend

Replace the last commit with your staged changes.

git reset --soft HEAD~1

Undo the last commit but keep changes staged.

git reset HEAD~1

Undo the last commit and keep changes unstaged.

git revert <commit>

Create a new commit that reverses an old one.

git reflog

Find recent HEAD positions and recover lost commits.

07

Stash work

Pause unfinished changes and restore them later.

6 commands
git stash

Temporarily store tracked, uncommitted changes.

git stash push -m "message"

Stash changes with a description you will recognize.

git stash -u

Stash tracked changes and untracked files.

git stash list

List saved stashes from newest to oldest.

git stash pop

Apply the latest stash and remove it from the list.

git stash apply stash@{0}

Apply a specific stash without deleting it.

08

History & releases

Search commits, reuse changes and mark versions.

7 commands
git log --author="name"

Find commits by a particular author.

git log --grep="text"

Search commit messages for matching text.

git log --follow -- <file>

Trace a file's history across renames.

git cherry-pick <commit>

Apply one existing commit to the current branch.

git tag

List the tags stored in the repository.

git tag -a v1.0.0 -m "Release v1.0.0"

Create an annotated tag for a release.

git bisect start

Begin a binary search for the commit that caused a bug.

Before you paste

Replace the placeholders

Text inside angle brackets is a placeholder, not part of the command. Replace it with your real value and omit the brackets.

Cheat sheetgit switch -c <branch>
Your commandgit switch -c checkout-fix
A safer Git reference

Use Git commands with confidence

This online Git command cheat sheet is organized by the task you are trying to finish, not by obscure flags. Search for an outcome, read the plain-language description and copy the exact command you need.

01

Check before changing

Run git status before a commit, merge, rebase or reset. It gives you the quickest picture of your current state.

02

Commit small units

Use git add -p to stage related hunks. Focused commits are easier to review, revert and understand later.

03

Protect shared history

Prefer git revert for changes already pushed to a shared branch. Use reset mainly for local, unpublished work.

Git command cheat sheet FAQs

What are the most common Git commands?

The most common Git commands are git status, git add, git commit, git pull, git push, git switch, git diff and git log. Together they cover checking your work, staging and saving changes, syncing, changing branches and reading history.

How do I copy a Git command from this cheat sheet?

Select the Copy button beside any command. You can also search or choose a category, then select Copy visible to copy the current results as a grouped reference. Replace any placeholder inside angle brackets before running the command.

How do I undo my last Git commit safely?

If the commit is local, git reset --soft HEAD~1 removes it while keeping the changes staged. If the commit was pushed or shared, git revert HEAD is usually safer because it preserves history and adds a new commit that reverses the change.

Is this Git command cheat sheet online free?

Yes. It is free to use online with no account, installation or sign-up. Search and copy interactions happen directly in your browser.

Does this work with GitHub, GitLab and Bitbucket?

Yes. The commands on this page are standard Git commands. They work with local repositories and with remotes hosted by GitHub, GitLab, Bitbucket or another Git hosting provider.