Developer Reference100% Free Quick ReferenceUpdated 2026-09-04

Git Commands Cheatsheet: Complete Architecture & Quick Reference

Everyday Git commands for cloning, staging, branching, stash, merge conflicts, and undoing commits.

Setup & Configuration

Set global author name

Sets the author name attached to all your commits.

git config --global user.name "Your Name"
Set global email

Sets the committer email address.

git config --global user.email "email@example.com"
Initialize new repository

Initializes a brand new .git directory in the current folder.

git init
Clone remote repository

Clones a remote repository to your local computer.

git clone <url>

Staging & Committing

Check working tree status

Shows modified, staged, and untracked files.

git status
Stage all changed files

Stages all modifications in the current directory.

git add .
Commit with message

Records staged snapshot with a descriptive message.

git commit -m "Commit message"
Stage and commit tracked files

Short-cut to stage modified tracked files and commit in one command.

git commit -am "Message"
Amend previous commit

Adds staged changes to the previous commit without changing the commit message.

git commit --amend --no-edit

Branching & Merging

Create & switch to new branch

Creates a new branch and checks it out immediately.

git switch -c <branch-name>
List all local branches

Lists existing local branches with the active branch marked.

git branch
Merge branch into active branch

Merges the specified branch into your currently checked out branch.

git merge <branch-name>
Delete branch safely

Deletes a branch only if it has already been merged.

git branch -d <branch-name>

Stashing & Temporary Storage

Stash uncommitted changes

Temporarily shelves modified tracked files to give you a clean working tree.

git stash
Apply and pop latest stash

Restores the most recently stashed changes and deletes them from the stash list.

git stash pop
List all stashes

Displays all saved stashes in the current repository.

git stash list

Undoing Mistakes

Discard uncommitted changes in file

Restores file to its state at HEAD, discarding local edits.

git restore <file>
Unstage file

Removes a file from the staging area without deleting its contents.

git restore --staged <file>
Undo last commit (keep changes)

Moves HEAD back 1 commit while leaving your edits staged.

git reset --soft HEAD~1
Revert a public commit safely

Creates a new inverse commit to cleanly undo changes on shared remote branches.

git revert <commit-hash>
Interactive MultiToolX Utility

Open Diff & Compare Tool

Compare two JSON values and find field-level differences.

Launch Free Tool

FAQ

Frequently Asked Questions

What is the difference between git reset and git revert?

git reset rewrites commit history locally (best for unpushed commits). git revert creates a brand new commit that inverts the changes, making it safe for public shared branches.

Explore More Technical Cheatsheets