1.8 KiB
1.8 KiB
Branching Traps
Branch Creation
git checkout -b featurefrom wrong branch = incorrect basegit branch featurewithout checkout = you stay on previous branch — commits go there- Branch name with spaces fails silently in some tools
/in branch name (feature/x) = some systems see it as directory
Switching
git checkout branchwith uncommitted changes = they may go to new branch — confusinggit switchis safer but-floses changes without warning- Auto stash doesn't exist — tracked changes are blocking, untracked get mixed
- Checkout of branch with different submodule = submodule stays in previous state
Merge
- Fast-forward merge doesn't create merge commit — linear history but no context
--no-ffalways creates merge commit — useful for features, noise for fixes- Merge of long branch = mega merge commit hard to review/revert
- Branch deleted after merge = orphan commits if no tag
Rebase
- Rebase of published branch = different history = others must
--forcepull - Bad interactive rebase can lose commits — use reflog to recover
- Conflicts in rebase: resolve EACH commit, not just once
- Rebase changes SHAs — CI/CD references to old commits broken
Remote Tracking
git push -u origin featureneeded first time — without-uit doesn't track- Remote branch deleted doesn't delete local tracking —
git fetch --pruneto clean git pullwithout upstream configured = error —git branch --set-upstream-to- Remote rename doesn't update tracking branches — reconfigure manually
Naming Conventions
- Same branch in two remotes (origin/main, upstream/main) = confusion
- Branch name case-insensitive on Mac/Windows, sensitive on Linux — CI bugs
- Branch named same as tag = ambiguity in some commands