Quick Reference
Git & GitHub Cheat Sheet
Every command from the course, organised by category. Print it, save it, reference it.
Starting out
git initStart tracking a folder with Gitgit clone <url>Copy a remote repo to your computergit statusSee what has changedSaving work
git add .Stage all changesgit add <file>Stage a specific filegit add -pStage changes interactively (line by line)git commit -m "message"Save staged changes as a snapshotgit log --onelineSee commit history (compact)GitHub (remote)
git remote add origin <url>Connect local repo to GitHubgit pushUpload commits to GitHubgit push -u origin mainFirst push — sets default remotegit pullDownload + merge changes from GitHubgit fetchDownload without mergingBranches
git switch -c <name>Create and switch to a new branchgit switch mainGo back to main branchgit branchList all branchesgit merge <branch>Merge a branch into currentgit branch -d <branch>Delete a branch (after merging)git push origin <branch>Push a branch to GitHubUndoing things
git restore <file>Discard unstaged changes to a filegit restore .Discard ALL unstaged changesgit restore --staged <file>Unstage a file (keep changes)git reset HEAD~1Undo last commit, keep changes unstagedgit reset --soft HEAD~1Undo last commit, keep changes stagedgit revert <hash>Safely undo a pushed commitgit stashTemporarily save uncommitted changesgit stash popRestore stashed changesInspecting
git diffSee unstaged changesgit diff --stagedSee staged changesgit log --oneline --graphVisual branch historygit show <hash>See what a commit changedgit blame <file>See who changed each lineTags & releases
git tag -a v1.0.0 -m "msg"Create an annotated taggit push origin --tagsPush all tags to GitHubgit tagList all tagsForks & open source
git remote add upstream <url>Add the original repo as upstreamgit fetch upstreamGet latest changes from upstreamgit merge upstream/mainMerge upstream changes into your branchConventional commit prefixes
feat:New featurefix:Bug fixdocs:Documentation onlychore:Maintenance, dependency updatesrefactor:Code change that isn't a feature or fixtest:Adding or fixing testsstyle:Formatting changes (no logic).gitignore essentials
node_modules/.env.env.localdist/.next/out/.DS_Store.cursor/*.log