Tools
Git
Everyday version control — branches, commits, undo, and rebase.
Getting started
git initInitialize a repogit clone <url>Clone a remote repogit statusShow working tree statusgit add <file>Stage a filegit add .Stage everythinggit commit -m "msg"Commit staged changesgit commit -am "msg"Stage tracked + commitBranches
git branchList branchesgit branch <name>Create branchgit switch <name>Switch branchgit switch -c <name>Create + switchgit merge <name>Merge into currentgit branch -d <name>Delete branchRemote
git remote -vList remotesgit fetchDownload objects/refsgit pullFetch + mergegit pushUpload commitsgit push -u origin <b>Push + set upstreamUndo & rewrite
git restore <file>Discard working changesgit restore --staged <f>Unstagegit commit --amendEdit last commitgit reset --soft HEAD~1Undo commit, keep changesgit reset --hard HEAD~1Undo commit + changesgit revert <hash>New commit that undoes one--hard is destructive: it discards uncommitted work.
Stash
git stashShelve changesgit stash listList stashesgit stash popApply + drop latestgit stash applyApply, keep stashgit stash dropDelete a stashRebase & history
git log --onelineCompact historygit rebase <branch>Replay commits on topgit rebase -i HEAD~3Interactive rebasegit cherry-pick <hash>Apply one commitgit diffUnstaged changesgit blame <file>Who changed each line