Git: Quick Commands

Git

Git: Quick Commands

Status and history

CommandAction
git status -sbShort status output
git log --oneline --graph --decorate -20Compact visual history
git diffUnstaged changes
git diff --stagedStaged changes

Daily workflow

CommandAction
git checkout -b feat/my-featureCreate a branch
git add .Stage changes
git commit -m "feat: ..."Create commit
git pull --rebase origin mainUpdate branch without merge commit
git push -u origin feat/my-featurePublish branch

Quick fixes

CommandAction
git commit --amendEdit last commit
git restore --staged <file>Unstage file
git restore <file>Discard local changes
git stash push -m "wip"Save temporary work
git stash popRestore stash

Tip

Use git pull --rebase to keep a cleaner, linear feature-branch history.