Tutorial Git Developer Tools DevOps

Free Git Commands Cheat Sheet Online — Interactive Reference for Developers

· 11 min read

Git is the backbone of modern software development. Every commit, branch, merge, and rebase flows through it. Yet despite being ubiquitous, Git is also famously difficult to remember. Even experienced developers find themselves searching for the exact flag to force-push safely, the correct way to unstage a file, or the difference between git restore and git reset. A printed cheat sheet taped to a monitor helps, but it ages quickly and cannot adapt to what you need in the moment. Our free interactive Git cheat sheet solves this problem. It organizes more than one hundred commands into ten searchable categories, provides concise descriptions, shows real-world examples, and lets you copy any command to your clipboard with a single click. Everything runs in your browser, so no data ever leaves your machine.

Why Developers Need a Git Cheat Sheet

Git is deep. The official documentation covers hundreds of commands, each with dozens of options. Most developers use only a small subset daily, but that subset varies by role, project, and workflow. A backend engineer working on a monorepo may need frequent stashing and interactive rebasing. A DevOps engineer may spend more time with submodules and worktrees. A frontend developer may primarily branch, commit, and push. No single developer memorizes every command, and that is perfectly normal.

The problem is not ignorance. It is retrieval friction. When you are in flow, switching contexts to look up a command breaks concentration. Opening a browser tab, typing a query, skimming Stack Overflow, and finding the right answer can take several minutes. A well-organized cheat sheet reduces that time to seconds. Better yet, an interactive cheat sheet filters commands by category and search terms, surfacing exactly what you need without scrolling through irrelevant entries.

What This Cheat Sheet Covers

Our Git command reference is organized into ten categories that map to real development workflows:

  • Basics — Repository initialization, cloning, staging, committing, and diffing.
  • Branching — Creating, switching, renaming, and deleting branches.
  • Merging — Merge strategies, aborting merges, and conflict resolution.
  • Remote — Working with remotes, fetching, pulling, and pushing.
  • Stash — Saving and restoring work-in-progress changes.
  • History — Browsing logs, blame, and statistics.
  • Rebase — Rewriting history interactively and resolving rebase conflicts.
  • Undo — Reverting, resetting, restoring, and cleaning.
  • Config — Setting user identity, aliases, editors, and credentials.
  • Advanced — Cherry-picking, bisecting, tagging, submodules, and worktrees.

Each command includes a one-line description, a realistic example, and its category tag. You can filter by category using the tab bar, or search by keyword to find commands across all categories.

Git Basics: Starting a Repository and Making Commits

Every Git workflow begins with the same handful of commands. Understanding these fundamentals thoroughly pays dividends because nearly everything else builds on them.

Creating and Cloning Repositories

To start tracking an existing project with Git, navigate to the project directory and initialize a repository:

git init

This creates a hidden .git directory that stores the entire history, configuration, and object database for the project. To work on an existing remote repository instead, clone it:

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

Cloning downloads the full repository history, all branches, and the default working tree. By default, the remote is named origin and the local branch tracks the remote default branch (usually main or master).

Checking Status and Staging Changes

Before committing, check what has changed:

git status

The status output shows three categories: changes staged for commit, changes not staged for commit, and untracked files. To stage a file for the next commit:

git add index.html

To stage all changes in the current directory, including modifications and deletions:

git add .

For finer control, use patch mode to stage individual hunks of a file:

git add -p

Patch mode is invaluable when a file contains both completed work and experimental changes that should not yet be committed.

Committing Changes

Once changes are staged, commit them with a descriptive message:

git commit -m "Fix navigation bug on mobile viewports"

If you have modified tracked files and want to stage and commit in one command:

git commit -am "Update heading styles across all pages"

Notice that -am only stages modifications to tracked files. New untracked files must still be added explicitly with git add.

If you make a mistake in the last commit message or forget to include a file, amend the commit:

git commit --amend -m "Corrected commit message"

Amending rewrites the most recent commit. If you have already pushed that commit to a shared remote, amending will require a force-push, which can disrupt collaborators.

Viewing Differences

To see what has changed but not yet been staged:

git diff

To see what has been staged and will be included in the next commit:

git diff --staged

To compare a specific file:

git diff src/app.js

Branching: Isolating Work

Branches are Git's superpower. They let you isolate features, experiments, and bug fixes without affecting the main codebase until you are ready to integrate them.

Creating and Switching Branches

List all local branches:

git branch

Create a new branch without switching to it:

git branch feature-login

Create a new branch and switch to it in one step:

git checkout -b feature-auth

Modern Git versions provide a clearer syntax for switching branches:

git switch develop

And for creating and switching simultaneously:

git switch -c hotfix-404

The switch command is preferred over checkout for branch operations because it will not accidentally overwrite files the way checkout can when given a path argument.

Deleting Branches

Delete a branch that has been fully merged:

git branch -d old-feature

Force delete a branch that has not been merged:

git branch -D experiment

Rename the current branch:

git branch -m main

Merging: Integrating Branches

When a feature branch is complete, merge it back into the main branch.

git merge feature-login

This performs a fast-forward merge if possible, or creates a merge commit if the branches have diverged. To always create a merge commit, even when a fast-forward is possible:

git merge --no-ff feature-auth

If a merge produces conflicts that you cannot resolve immediately, abort it:

git merge --abort

To merge a branch but squash all its commits into a single staged change:

git merge --squash feature-login

Squashing is useful when a feature branch contains many small, exploratory commits that you do not want to preserve in the main branch history.

Remote Operations: Synchronizing with Others

Git is a distributed version control system, which means every clone is a full copy of the repository. Remotes are simply references to other copies that you synchronize with.

Inspecting and Managing Remotes

Show all configured remotes and their URLs:

git remote -v

Add a new remote:

git remote add upstream https://github.com/original/repo.git

Rename a remote:

git remote rename origin upstream

Remove a remote:

git remote remove origin

Fetching and Pulling

Download commits and refs from the default remote without modifying your working tree:

git fetch

Fetch from a specific remote:

git fetch upstream

Fetch and merge changes from the remote tracking branch into your current branch:

git pull origin main

If you prefer a linear history, fetch and rebase your local commits on top of the remote changes:

git pull --rebase origin main

Pushing

Send your local commits to the remote:

git push origin main

Push a new branch and set it to track the remote:

git push -u origin feature-x

The -u flag establishes an upstream relationship, so future git push and git pull commands on that branch will default to the correct remote and branch.

Force push overwrites remote history. Use it only when you are certain no one else has based work on the remote branch:

git push --force origin main

A safer alternative is force-with-lease, which fails if the remote has new commits you have not seen:

git push --force-with-lease origin main

Delete a remote branch:

git push --delete origin old-branch

Stashing: Saving Work in Progress

Sometimes you need to switch branches or pull changes, but your working tree is messy with unfinished work. Stashing saves your current changes without committing them.

Stash all changes with a default message:

git stash

Stash with a descriptive message:

git stash push -m "WIP: auth refactor"

List all stashes:

git stash list

Apply the most recent stash and remove it from the list:

git stash pop

Apply the most recent stash but keep it in the list:

git stash apply

Apply a specific stash by index:

git stash apply stash@{1}

Drop a stash:

git stash drop

Remove all stashes:

git stash clear

Create a new branch from a stash and pop it:

git stash branch bugfix-stash

History: Understanding What Happened

Git keeps a complete history of every change. Learning to navigate that history efficiently is essential for debugging, code review, and documentation.

Show commit history:

git log

Compact one-line history:

git log --oneline

Visual branch graph:

git log --graph --oneline --all

History with file change statistics:

git log --stat

Filter by author:

git log --author="Alice"

Filter by date:

git log --since="2024-01-01" --until="2024-01-31"

History for a specific file:

git log -- src/app.js

Search commit messages:

git log --grep="bugfix"

Show details of a specific commit:

git show abc1234

See who last modified each line of a file:

git blame index.html

Summarize commits grouped by author:

git shortlog -sn

Rebase: Rewriting History

Rebasing replays your branch's commits on top of another branch, producing a linear history. It is an alternative to merging that avoids merge commits but rewrites commit hashes.

Rebase the current branch onto another:

git rebase main

Interactive rebase to edit, squash, or reorder commits:

git rebase -i HEAD~3

Continue after resolving conflicts:

git rebase --continue

Abort a rebase:

git rebase --abort

Skip the current patch:

git rebase --skip

Because rebasing rewrites history, never rebase commits that have already been pushed to a shared remote unless you coordinate with your team.

Undo: Recovering from Mistakes

Everyone makes mistakes. Git provides multiple ways to undo changes depending on what needs to be recovered.

Discard unstaged changes in a file:

git restore index.html

Unstage a file but keep its changes:

git restore --staged index.html

Undo the last commit but keep changes staged:

git reset --soft HEAD~1

Undo the last commit and keep changes unstaged:

git reset --mixed HEAD~1

Undo the last commit and discard all changes:

git reset --hard HEAD~1

Be extremely careful with --hard. It permanently discards uncommitted changes. If you accidentally use it, check git reflog immediately to recover lost commits.

Create a new commit that undoes a previous commit:

git revert abc1234

Unlike reset, revert is safe for shared history because it creates a new commit rather than rewriting existing ones.

Remove untracked files and directories:

git clean -fd

Configuration: Personalizing Git

Git stores configuration at three levels: system, global, and local. Most personal settings belong in the global config file.

Set your username and email:

git config --global user.name "Alice Smith"
git config --global user.email "alice@example.com"

Set the default branch name for new repositories:

git config --global init.defaultBranch main

Set your preferred text editor:

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

Create command aliases:

git config --global alias.st status
git config --global alias.co checkout
git config --global alias.br branch
git config --global alias.ci commit

Cache credentials for a period of time:

git config --global credential.helper cache

View all settings:

git config --list

Advanced Commands

These commands are less common but invaluable in specific situations.

Apply a single commit from another branch:

git cherry-pick abc1234

Find the commit that introduced a bug using binary search:

git bisect start
git bisect bad
git bisect good v1.0

Create and manage tags:

git tag
git tag v1.0.0
git tag -a v1.0.0 -m "Initial release"
git push --tags

View the reference log to recover lost commits:

git reflog

Add a submodule:

git submodule add https://github.com/user/lib.git

Create a linked working tree for another branch:

git worktree add ../fix-branch hotfix

Using the Interactive Cheat Sheet

Our online Git cheat sheet puts all of these commands at your fingertips. The interface is organized into category tabs, so you can narrow your view to only the commands relevant to your current task. A search bar filters commands in real time across all categories. Each card shows the command, a concise description, and a realistic example. Click the Copy button to paste the command directly into your terminal.

The visual design follows The Archivist's Card Catalog aesthetic — warm archival paper tones, deep ink typography, brass accents, and a structured grid that makes scanning effortless. Commands are color-coded by category, and syntax highlighting makes flags and arguments easy to spot.

Related Tools

Frequently Asked Questions

Is this Git cheat sheet free?

Yes. The tool is completely free with no limits, no registration, and no advertisements.

How many commands are included?

The cheat sheet contains over one hundred commands across ten categories, covering the vast majority of daily Git workflows.

Can I search for commands?

Yes. The search bar filters commands in real time by command name, description, or example content.

Is my data safe?

Yes. The cheat sheet is one hundred percent client-side. No commands or usage data are sent to a server.

Does this replace the official Git documentation?

No. This cheat sheet is a quick reference for common commands. For deep understanding of Git internals, plumbing commands, and edge cases, consult the official git-scm.com documentation.

Conclusion

Git is a powerful tool with a steep learning curve. Even after years of daily use, most developers still look up commands they do not use frequently. Our free interactive Git cheat sheet removes the friction from that lookup process. With over one hundred commands organized into searchable categories, realistic examples for every entry, and one-click copying, it is the fastest way to find the Git command you need without breaking your flow. Bookmark it, share it with your team, and keep shipping.

Found this useful? Check out our free developer tools or browse more articles.