🛠️ ToolsPilot
← Back to ToolsPilot

Git Cheat Sheet

Essential Git commands for daily use. Bookmark this page or print it.

Setup

git config --global user.name "name"Set username
git config --global user.email "email"Set email
git initInitialize repo
git clone <url>Clone repo

Basic

git statusCheck status
git add .Stage all changes
git commit -m "msg"Commit changes
git pushPush to remote
git pullPull from remote

Branching

git branchList branches
git branch <name>Create branch
git checkout <name>Switch branch
git checkout -b <name>Create & switch
git merge <name>Merge branch
git branch -d <name>Delete branch

Undo

git reset HEAD~1Undo last commit
git checkout -- <file>Discard changes
git revert <hash>Revert commit
git stashStash changes
git stash popApply stash

Remote

git remote -vList remotes
git remote add <name> <url>Add remote
git push -u origin <branch>Push & track
git fetchFetch updates

Log

git logView log
git log --onelineCompact log
git log --graphVisual log
git diffView changes
git blame <file>View who changed what