Git Command Cheatsheet
A searchable reference of the most useful git commands.
● runs in your browserSetup & Config
git config --global user.name "Name"set your commit namegit config --global user.email "you@x.com"set your commit emailgit initcreate a new repo in this foldergit clone <url>copy a remote repo locallyDaily Workflow
git statusshow changed/staged filesgit add <file>stage a file (use . for all)git commit -m "msg"commit staged changesgit commit -am "msg"stage tracked + commit in one stepgit pullfetch + merge from remotegit pushsend commits to remoteBranches
git branchlist local branchesgit switch -c <name>create & switch to a new branchgit switch <name>switch to an existing branchgit merge <name>merge a branch into currentgit branch -d <name>delete a merged branchUndo & Fix
git restore <file>discard unstaged changes to a filegit restore --staged <file>unstage a filegit commit --amendedit the last commitgit reset --hard HEADdiscard ALL local changes (careful)git revert <hash>make a new commit undoing oneInspect & History
git log --oneline --graphcompact visual historygit diffshow unstaged changesgit diff --stagedshow staged changesgit blame <file>who changed each linegit stash / git stash popshelve / restore work in progressRemotes
git remote -vlist remotesgit remote add origin <url>add a remotegit push -u origin <branch>push & set upstreamgit fetch --alldownload all remote changes