Skip to content
🌿 Version Control

Git Cheat Sheet

This Git cheat sheet covers the essential commands for daily work: staging and committing, branching and merging, working with remotes, inspecting history, and safely undoing changes. Use the search box to filter commands instantly.

Setup & Config

Set the name attached to your commits
Set the email attached to your commits
Create a new Git repository in the current folder
Copy a remote repository locally

Staging & Committing

Show changed, staged and untracked files
Stage a file for the next commit
Stage all changes (new, modified, deleted)
Commit staged changes with a message
Edit the most recent commit

Branching & Merging

List local branches
Create and switch to a new branch
Switch to an existing branch
Merge a branch into the current one
Reapply commits on top of another branch

Remotes

List configured remotes
Upload local commits to the remote
Push and set the upstream branch
Fetch and merge remote changes
Download remote changes without merging

Inspecting History

Compact, visual commit history
Show unstaged changes
Show staged changes
Show who last changed each line

Undoing Changes

Discard unstaged changes to a file
Unstage a file, keeping changes
Undo last commit, keep changes staged
Create a new commit that undoes another
Temporarily shelve uncommitted changes