ā ļø Rule: Never rebase commits already pushed to shared branches!
Merge Strategies
Resolve Conflicts
Cherry-pick
Tags
Remotes
Push & Pull š„
Tracking Branches
Fetch vs Pull
Reset vs Revert vs Restore ā Know the Difference
Common Undo Scenarios
Reflog ā Your Safety Net š„
š” If you did a bad reset --hard, reflog can save you. Always check it first!
Stash Commands
Stash Partial Changes
Interactive Rebase
Bisect ā Find Buggy Commit
Submodules
Hooks
Other Power Commands
Worktrees
Feature Branch Workflow
Hotfix Workflow
Squash Before Merge
Oops Recovery Recipes
All Essential Commands at a Glance
Gotchas & Tricky Parts š„
git push --force vs --force-with-lease ā Always use --force-with-lease. It fails if someone else pushed since you last fetched, preventing overwriting their work.
Detached HEAD ā Happens when you checkout a commit directly. Git warns you. Always create a branch if you want to keep changes made here.
merge vs rebase ā Rebase rewrites history. Never rebase commits pushed to shared branches (main, dev). Safe to rebase local feature branches.
git pull = fetch + merge ā Many people forget pull does a merge. Prefer git pull --rebase for cleaner history.
Untracked files in stash ā git stash only stashes tracked files by default. Use git stash -u to include untracked, or -a for ignored too.