Git CommandsCheat Sheet

Master Git with our comprehensive command reference and interactive scenario calculator. From basic operations to advanced workflows, find exactly what you need.

Essential Git Commands

Quick reference for the most commonly used Git commands, organized by category

Basic Commands

Fundamental Git operations every developer should know

git init

Initialize a new Git repository

git clone <url>

Clone a repository from a remote URL

git add <file>

Add files to staging area

git add .

Add all files to staging area

git commit -m "message"

Commit staged changes with a message

git status

Show the working tree status

git log

Show commit history

Branching

Create, switch, and manage Git branches effectively

git branch

List all branches

git branch <name>

Create a new branch

git checkout <branch>

Switch to a branch

git checkout -b <branch>

Create and switch to a new branch

git merge <branch>

Merge a branch into current branch

git branch -d <branch>

Delete a branch

Rebasing

Reapply commits on top of different bases for cleaner history

git rebase <branch>

Reapply commits on top of another branch

git rebase -i HEAD~3

Interactive rebase of last 3 commits

git rebase --onto <new-base> <old-base>

Rebase onto a different base commit

git rebase --continue

Continue rebase after resolving conflicts

git rebase --abort

Abort rebase and return to original state

git rebase --skip

Skip current commit during rebase

Remote Operations

Collaborate with remote repositories and teams

git remote add origin <url>

Add a remote repository

git push origin <branch>

Push changes to remote branch

git pull origin <branch>

Pull changes from remote branch

git fetch

Fetch changes from remote without merging

git push -u origin <branch>

Push and set upstream branch

Undoing Changes

Safely undo and recover from mistakes

git reset HEAD <file>

Unstage a file

git reset --hard HEAD

Reset to last commit (destructive)

git revert <commit>

Create a new commit that undoes changes

git checkout -- <file>

Discard changes in working directory

git stash

Temporarily save changes

git stash pop

Apply stashed changes

Learn Git Deeply

Dive deeper into Git concepts and workflows with our comprehensive guides

Git FundamentalsFeatured

How Git Works: Understanding Version Control Fundamentals

Learn the core concepts behind Git version control, from snapshots and commits to branching and merging.

Jan 15, 2024
8 min read
Workflow StrategyFeatured

GitFlow Workflow: A Comprehensive Guide to Branching Strategy

Explore the GitFlow workflow, a structured branching model for managing feature development, releases, and hotfixes.

Jan 20, 2024
12 min read

Need Help Building Commands?

Use our interactive scenario calculator to build the perfect Git command for your situation