Git Command Cheat Sheet
Quick reference for common Git commands. Search below or click a command to copy it.
Setup & config
git config --global user.name "Your Name"Set your namegit config --global user.email "you@example.com"Set your emailgit initInitialize a new repogit clone <url>Clone a repository
Daily workflow
git statusShow working tree statusgit add .Stage all changesgit add <file>Stage specific file(s)git commit -m "message"Commit with messagegit commit -am "message"Stage tracked files and commitgit pushPush to remotegit pullFetch and merge from remote
Branching
git branchList local branchesgit branch -aList all branches (incl. remote)git branch <name>Create a new branchgit checkout <branch>Switch to branchgit checkout -b <branch>Create and switch to branchgit switch <branch>Switch branch (newer)git switch -c <branch>Create and switch (newer)git merge <branch>Merge branch into currentgit branch -d <branch>Delete merged branch
Remote
git remote -vList remotesgit remote add origin <url>Add remotegit push -u origin <branch>Push and set upstreamgit fetch originFetch from remotegit pull origin <branch>Pull specific branch
Stash
git stashStash changesgit stash listList stashesgit stash popApply and remove top stashgit stash applyApply top stash, keep itgit stash dropDrop top stash
Undo & reset
git restore <file>Discard changes in working treegit restore --staged <file>Unstage filegit reset --soft HEAD~1Undo last commit, keep changes stagedgit reset --mixed HEAD~1Undo last commit, keep changes unstagedgit reset --hard HEAD~1Undo last commit, discard changes
Log & history
git logCommit historygit log --onelineCompact one-line loggit log -pLog with patchesgit diffUnstaged changesgit diff --stagedStaged changes
Other
git tag <tagname>Create lightweight taggit tag -a <tagname> -m "message"Create annotated taggit push --tagsPush all tagsgit clean -fdRemove untracked files/dirsgit rebase <branch>Rebase current branch onto branch
Example
Search for push or branch to find relevant commands. Click Copy next to any command to copy it to your clipboard.
FAQ
<branch> with a real branch name, <file> with a filename, and <url> with a repository URL.
Data Transformation Tools
JSON Formatter & Validator
Format, minify, and validate JSON with error messages and line numbers.
SQL Formatter
Beautify SQL with indentation and uppercase keywords.
CSV Header Validator
Detect duplicate or empty headers and column count issues.
Regex Tester
Test regex patterns, highlight matches, and show capture groups.
Timestamp Converter
Unix timestamp to date, date to timestamp, timezone, current time.
Color Converter
Convert HEX, RGB, HSL. Color preview and copy.
JSON Diff Tool
Compare two JSON objects. See added, removed, changed.
Text Diff Checker
Compare two text blocks. Highlight additions and deletions.
JSON ↔ PHP Array Converter
Convert JSON to PHP array syntax and PHP array to JSON.
Lorem Ipsum Generator
Generate paragraphs, sentences, or words.
Case Converter
UPPERCASE, lowercase, camelCase, PascalCase, snake_case, kebab-case.
Text Statistics
Word count, character count, sentence count, reading time.
SQL Query Generator
Build SELECT with table, columns, WHERE, LIMIT.