Searchable reference of common Git commands for everyday work.
git initCreate a new repository
git clone <url>Clone a remote repository
git statusShow working tree status
git add -AStage all changes
git commit -m "msg"Commit staged changes
git commit --amendAmend the last commit
git branchList branches
git switch -c <name>Create and switch to a branch
git switch <name>Switch branches
git merge <name>Merge a branch into current
git rebase <base>Reapply commits onto base
git branch -d <name>Delete a branch
git remote -vList remotes
git fetchDownload objects/refs
git pullFetch and merge
git pushUpload commits
git push -u origin <br>Push and set upstream
git log --oneline --graphCompact visual history
git diffUnstaged changes
git restore <file>Discard working changes
git restore --staged <f>Unstage a file
git reset --hard <ref>Reset branch to ref (destructive)
git revert <ref>Create a commit that undoes ref
git stashStash working changes
git stash popReapply and drop latest stash
git stash listList stashes
git show <ref>Show a commit
git blame <file>Who changed each line
git reflogHistory of HEAD moves (recovery)