Git Cheat Sheet
Essential Git commands for daily use. Bookmark this page or print it.
Setup
git config --global user.name "name"Set usernamegit config --global user.email "email"Set emailgit initInitialize repogit clone <url>Clone repoBasic
git statusCheck statusgit add .Stage all changesgit commit -m "msg"Commit changesgit pushPush to remotegit pullPull from remoteBranching
git branchList branchesgit branch <name>Create branchgit checkout <name>Switch branchgit checkout -b <name>Create & switchgit merge <name>Merge branchgit branch -d <name>Delete branchUndo
git reset HEAD~1Undo last commitgit checkout -- <file>Discard changesgit revert <hash>Revert commitgit stashStash changesgit stash popApply stashRemote
git remote -vList remotesgit remote add <name> <url>Add remotegit push -u origin <branch>Push & trackgit fetchFetch updatesLog
git logView loggit log --onelineCompact loggit log --graphVisual loggit diffView changesgit blame <file>View who changed what