Every Git command you actually need, organized logically. Stop Googling how to undo a rebase or delete a remote branch. Search, copy, and get back to coding.
git config --global user.name "Name"Set your commit author name globally
git config --global user.email "email"Set your commit author email globally
git config --listList all config settings
git initInitialize a new local repository
git clone <url>Clone a remote repository locally
git clone <url> <dir>Clone into a specific directory name
git add <file>Stage a specific file
git add .Stage all changes in the current directory
git add -pInteractively stage chunks of changes
git reset HEAD <file>Unstage a file, keep changes
git commit -m "message"Commit staged changes with a message
git commit --amendModify the most recent commit
git revert <hash>Create a new commit that undoes a given commit
git reset --soft HEAD~1Undo last commit, keep changes staged
git reset --hard HEAD~1Undo last commit, discard changes
git branchList local branches
git branch <name>Create a new branch
git checkout <branch>Switch to an existing branch
git checkout -b <branch>Create and switch to a new branch
git branch -d <branch>Delete a merged branch
git branch -D <branch>Force delete a branch (unmerged)
git merge <branch>Merge a branch into the current branch
git rebase <branch>Rebase current branch onto another
git rebase --abortAbort an in-progress rebase
git cherry-pick <hash>Apply a specific commit to the current branch
git remote -vList remote connections with URLs
git remote add origin <url>Add a remote named origin
git fetch originDownload remote changes without merging
git pull origin <branch>Fetch and merge remote branch
git push origin <branch>Push local branch to remote
git push -u origin <branch>Push and set upstream tracking
git statusShow working tree status
git log --onelineCompact one-line commit history
git log --graph --onelineBranch graph with one-line history
git diffShow unstaged changes
git diff --stagedShow staged changes
git blame <file>Show who changed each line of a file
git stashStash current uncommitted changes
git stash popApply the most recent stash and remove it
git stash listList all stashes
git stash dropDiscard the most recent stash
git tag <name>Create a lightweight tag at HEAD
git tag -a <name> -m "msg"Create an annotated tag with message
git push origin --tagsPush all tags to remote
Designed specifically for developers in a state of panic.
You don't need to know the command. Search for "delete branch" and we will show you the exact git syntax to use.
Commands are separated into intuitive categories: Setup, Branching, Undoing Mistakes, and Remote syncing.
Click any snippet to copy it directly to your clipboard so you can paste it into your terminal without typos.
If you are stuck, type what you are trying to achieve (e.g., "rename branch") in the search box at the top.
Read the description next to the command. Pay special attention to whether the command includes a `--hard` or `--force` flag, as these can be destructive.
Click the command block to copy it. Paste it into your terminal, replacing the bracketed text (like `[branch-name]`) with your actual variables.
Git is the industry standard for version control, but it is notoriously hostile to beginners. Created by Linus Torvalds for managing the Linux kernel, Git was built for maximum power and flexibility, not user-friendliness. As a result, its command-line interface is famously inconsistent.
A reliable Git cheatsheet is a mandatory tool for any developer. Even senior engineers frequently forget the exact syntax required to delete a remote tag or squash the last three commits during an interactive rebase.
To truly understand the commands in this cheatsheet, you must understand the three "trees" that Git manages: