The Essential Git Cheatsheet: Every Command You Need to Know

A comprehensive Git cheatsheet covering basic commands, branching, viewing history, undoing changes, and tips for developers of all skill levels.

February 1, 2026

Why Every Developer Needs a Git Cheatsheet

Git is the world's most widely used version control system, and for good reason. It powers collaboration for millions of developers across open-source projects, startups, and enterprise teams alike. However, Git's extensive command set can be overwhelming, even for experienced developers. A well-organized cheatsheet serves as a quick reference that saves time, prevents mistakes, and helps you stay productive.

Whether you are a beginner learning version control for the first time or a senior engineer who occasionally forgets the exact syntax for an interactive rebase, having a reliable Git reference at your fingertips is invaluable.

Basic Git Commands

These foundational commands are the building blocks of every Git workflow:

  • git init — Initialize a new Git repository in the current directory. This creates the hidden .git folder that tracks all changes.
  • git clone [url] — Create a local copy of a remote repository. This downloads the entire history and all branches.
  • git add [file] — Stage changes for the next commit. Use git add . to stage all modified files at once.
  • git commit -m "message" — Record staged changes with a descriptive message. Good commit messages explain why a change was made, not just what changed.
  • git push — Upload local commits to the remote repository, making them available to your team.
  • git pull — Fetch and merge changes from the remote repository into your current branch.

Branching and Merging

Branches are one of Git's most powerful features, enabling parallel development without conflicts:

  • git branch — List all local branches. Add -a to see remote branches as well.
  • git branch [name] — Create a new branch from the current commit.
  • git checkout [branch] — Switch to an existing branch. Modern Git also supports git switch [branch].
  • git checkout -b [name] — Create and switch to a new branch in one step.
  • git merge [branch] — Merge the specified branch into your current branch. This creates a merge commit if there are divergent changes.
  • git rebase [branch] — Reapply your commits on top of another branch, creating a linear history. Use with care on shared branches.

Viewing History and Status

Understanding what has changed and when is crucial for effective collaboration:

  • git status — Show the current state of your working directory and staging area. This reveals which files are modified, staged, or untracked.
  • git log — Display the commit history. Add --oneline for a compact view or --graph for a visual branch diagram.
  • git diff — Show unstaged changes in your working directory. Use git diff --staged to see changes that are ready to commit.
  • git show [commit] — Display detailed information about a specific commit, including the full diff.
  • git blame [file] — Show who last modified each line of a file, along with the commit hash and date.

Undoing Changes

Mistakes happen, and Git provides several ways to recover:

  • git reset [file] — Unstage a file without discarding its changes. The changes remain in your working directory.
  • git reset --hard [commit] — Reset your branch to a specific commit, discarding all subsequent changes. Use this with extreme caution.
  • git revert [commit] — Create a new commit that undoes the changes from a specific commit. This is the safe way to undo changes on shared branches.
  • git stash — Temporarily save uncommitted changes so you can switch branches. Use git stash pop to restore them later.
  • git checkout -- [file] — Discard changes in a specific file, reverting it to the last committed state.

Advanced Tips

Writing Better Commit Messages

A good commit message starts with a concise summary line (50 characters or fewer), followed by a blank line and a more detailed explanation if needed. Use the imperative mood: "Add feature" rather than "Added feature."

Using Git Aliases

Speed up your workflow by creating aliases for common commands. For example, git config --global alias.co checkout lets you type git co instead of the full command.

Interactive Staging

Use git add -p to stage individual chunks of changes within a file. This helps you create focused, atomic commits even when you have made multiple unrelated changes.

How Simple-Toolz Helps

Our interactive Git Cheatsheet on Simple-Toolz organizes all essential Git commands into searchable, categorized sections. Unlike a static PDF or bookmark, our tool lets you quickly filter commands by category, search by keyword, and find exactly what you need in seconds. It is always up to date, works in your browser, and requires no installation. Bookmark it and never waste time searching for Git syntax again.