Git Essentials
git config --global user.name "Your Name"git config --global user.email "you@example.com"Daily Workflow
Section titled “Daily Workflow”git status # what changed?git add <file> # stage a specific filegit add . # stage all changesgit commit -m "message" # commit staged changesgit push # push to remotegit pull # pull latest from remoteBranches
Section titled “Branches”git branch # list all branchesgit branch <name> # create a new branchgit switch <name> # switch to branchgit switch -c <name> # create and switch in one stepgit merge <name> # merge branch into currentgit branch -d <name> # delete a merged branch (safe)git branch -D <name> # force-delete a branchgit stash # stash all uncommitted changesgit stash pop # restore and remove last stashgit stash list # show all stashesgit stash drop # discard last stashgit restore <file> # discard unstaged changes in a filegit restore --staged <file> # unstage a file (keep changes)git revert <commit> # create a new undo commit (safe, keeps history)git reset --hard HEAD~1 # remove last commit and its changes (destructive)Inspect
Section titled “Inspect”git log --oneline -10 # last 10 commits, compact viewgit diff # unstaged changesgit diff --staged # staged changes not yet committedgit show <commit> # full details of a specific commitgit blame <file> # who changed each line and when