Git Cheatsheet

// Common Git commands organized by workflow

git initInitialize a new Git repository
git clone <url>Clone a remote repository
git config --global user.name "Name"Set your name for commits
git config --global user.email "email"Set your email for commits
git config --listList all configuration settings
git remote add origin <url>Add a remote repository
git remote -vList remote repositories
git statusShow working tree status
git add <file>Stage a specific file
git add .Stage all changes in current directory
git add -pInteractively stage hunks
git commit -m "message"Commit staged changes with message
git commit --amendAmend the last commit
git commit --amend --no-editAmend last commit without changing message
git reset HEAD <file>Unstage a file (keep changes)
git reset --soft HEAD~1Undo last commit (keep changes staged)
git reset --hard HEAD~1Undo last commit (discard changes)
git checkout -- <file>Discard changes in working directory
git restore <file>Discard changes in working directory (modern)
git restore --staged <file>Unstage a file (modern)
git stashStash uncommitted changes
git stash popApply and remove latest stash
git stash listList all stashes
git stash dropDelete latest stash
git branchList local branches
git branch -aList all branches (local + remote)
git branch <name>Create a new branch
git branch -d <name>Delete a branch (safe)
git branch -D <name>Force delete a branch
git switch <branch>Switch to a branch (modern)
git switch -c <branch>Create and switch to new branch
git checkout <branch>Switch to a branch (classic)
git checkout -b <branch>Create and switch to new branch (classic)
git merge <branch>Merge branch into current branch
git merge --no-ff <branch>Merge with a merge commit (no fast-forward)
git rebase <branch>Rebase current branch onto branch
git rebase --abortAbort an in-progress rebase
git rebase --continueContinue rebase after resolving conflicts
git cherry-pick <commit>Apply a specific commit to current branch
git fetchDownload objects from remote (no merge)
git fetch --pruneFetch and remove stale remote branches
git pullFetch and merge remote changes
git pull --rebaseFetch and rebase on remote changes
git pushPush commits to remote
git push -u origin <branch>Push and set upstream branch
git push --force-with-leaseForce push (safer, checks remote state)
git push origin --delete <branch>Delete a remote branch
git push --tagsPush all tags to remote
git logShow commit history
git log --onelineShow commit history (compact)
git log --graph --onelineShow commit graph
git log -p <file>Show changes over time for a file
git diffShow unstaged changes
git diff --stagedShow staged changes
git diff <branch1>..<branch2>Compare two branches
git show <commit>Show details of a specific commit
git blame <file>Show who changed each line of a file
git reflogShow history of HEAD changes
git bisect startStart binary search for a bug
git shortlog -snShow commit count by author
git tagList all tags
git tag <name>Create a lightweight tag
git tag -a <name> -m "msg"Create an annotated tag
git tag -d <name>Delete a local tag
git push origin <tag>Push a specific tag to remote

#About Git Cheatsheet

Free online Git cheatsheet. Quick reference for common Git commands organized by workflow: setup, staging, branching, merging, remote, and history. This tool runs entirely in your browser — your data is never sent to a server. Just paste your input, get instant results, and copy with one click. No sign-up or installation required.

#FAQ

What are the most essential Git commands?
The most essential Git commands are git init, git clone, git add, git commit, git push, git pull, git branch, git checkout/switch, git merge, and git status. These cover the basic workflow of creating, tracking, and sharing changes.
What is the difference between git merge and git rebase?
git merge creates a new merge commit that combines two branches, preserving the full history. git rebase replays commits from one branch onto another, creating a linear history. Rebase is cleaner but should not be used on shared/public branches.
</> Embed this tool

Copy this code to embed the tool on your website. Adjust the height to fit your layout.

<iframe src="https://www.browserutils.dev/embed/git-cheatsheet" width="100%" height="500" frameborder="0" title="Git Cheatsheet"></iframe>

#Related