Git Commands Cheat Sheet: The 40 You’ll Actually Use

Git runs from the command line, so instead of keyboard shortcuts you get commands. Here are the 40 most people use every week, grouped by what you’re trying to do.

We checked every one against Git reference documentation (git-scm.com) on October 21, 2026.

Setup


CommandWhat it does
git config –global user.name “Your Name”Set the name saved with your commits
git config –global user.email “[email protected]”Set the email saved with your commits
git config –global –editOpen your global Git settings in a text editor
git initCreate a new repository in the current folder
git clone <url>Copy a remote repository to your computer

Everyday Changes


CommandWhat it does
git statusShow changed, staged and untracked files
git diffShow changes you have not staged yet
git diff –stagedShow changes that are staged for the next commit
git add <file>Stage one file for the next commit
git add .Stage all changes in the current folder
git commit -m “message”Commit staged changes with a message
git commit -am “message”Stage and commit all changes to tracked files
git restore <file>Throw away unstaged changes to a file
git restore –staged <file>Unstage a file but keep your changes
git reset HEAD <file>Unstage a file (older form of restore –staged)
git checkout — <file>Throw away changes to a file (older form of restore)

Branches


CommandWhat it does
git branchList branches
git branch <name>Create a new branch
git branch -d <name>Delete a branch that has been merged
git switch <name>Switch to another branch
git switch -c <name>Create a new branch and switch to it
git checkout <name>Switch to another branch (older form)
git checkout -b <name>Create and switch to a new branch (older form)
git merge <name>Merge another branch into the current branch

Remotes


CommandWhat it does
git remote -vList remote repositories and their URLs
git remote add origin <url>Add a remote repository named origin
git fetchDownload new commits from the remote without merging
git pullDownload and merge changes from the remote
git pull origin <branch>Pull one branch from the remote
git pushUpload your commits to the remote
git push -u origin <branch>Push a branch and set it to track the remote

History


CommandWhat it does
git logShow the commit history
git log –onelineShow the history one line per commit
git show <commit>Show the changes in one commit
git tag <name>Tag the current commit, for example v1.0

Undo and Stash


CommandWhat it does
git stashSet aside uncommitted changes for later
git stash popBring back the most recently stashed changes
git revert <commit>Make a new commit that undoes an earlier commit
git reset –hard <commit>Move back to a commit and throw away later changes
git clean -fdDelete untracked files and folders

Good to know: These are commands you type in a terminal (Command Prompt, PowerShell or Git Bash), not hotkeys. Replace anything in <angle brackets> with your own value.

Good to know: git reset –hard and git clean -fd delete work for good. Run git status first.

Get the Excel and PDF Version


Everything above is free. Bookmark this page and use it anytime.

If you’d rather have it on your desk, the download below is a sortable Excel file plus a printable one-page PDF of all 40 commands, for $0.99.

Want One Key to Do More?


Typing the same Git commands over and over? These tools let you fire them with a hotkey you pick:

Comments are closed.