Converter Web ToolsConverter WebTools

Git Cheat Sheet — Common Commands

This Git cheat sheet lists the most-used Git commands for everyday version control — setting up a repo, staging and committing, branching, working with remotes, inspecting history and undoing changes.

Setup & create

CommandWhat it does
git config --global user.name "Name"Set your commit name
git config --global user.email [email protected]Set your commit email
git initStart a new repository
git clone <url>Copy a remote repository

Stage & commit

CommandWhat it does
git statusShow changed files
git add <file>Stage a file
git add .Stage everything
git commit -m "message"Commit staged changes
git commit -am "message"Stage tracked files and commit

Branches

CommandWhat it does
git branchList branches
git switch -c <name>Create and switch to a branch
git switch <name>Switch branch
git merge <name>Merge a branch into current
git branch -d <name>Delete a branch

Remotes

CommandWhat it does
git remote add origin <url>Link a remote
git push -u origin mainPush and set upstream
git pushUpload commits
git pullFetch and merge from remote
git fetchDownload without merging

Inspect & undo

CommandWhat it does
git log --onelineCompact history
git diffShow unstaged changes
git restore <file>Discard file changes
git reset --hardReset to last commit
git revert <commit>Undo a commit safely
git stashShelve changes
git stash popRestore shelved changes

Related tools & charts