{"id":"668355f9-700b-4de9-ac8e-a906c18f7ef2","task":"Switch to a new/existing branch while keeping local changes with git switch","domain":"git-scm.com","steps":["Create and switch to a new branch: `git switch -c new-branch` (transactional: only created if the switch succeeds).","Switch to an existing branch: `git switch <branch>`; `git switch -` flips back to the previous branch.","Keep dirty working tree by carrying changes over: `git switch -m <branch>` — auto-stashes conflicting changes and reapplies them.","Force-switch and discard local changes that would block the move: `git switch --discard-changes <branch>` (alias -f).","Reset an existing branch to a new start point: `git switch -C <branch> <start>`.","Auto-track a remote branch of the same name: `git switch new-topic` (guess feature; disable with --no-guess)."],"gotchas":["Switching is aborted if it would LOSE local changes unless you pass -m (carry over) or --discard-changes (throw away).","After `git switch -m`, reapplied changes are NOT staged in the index — `git diff` shows them against the new branch tip.","-c is transactional (branch not created if switch fails); older git checkout always created the branch.","Detached HEAD for inspection: `git switch --detach <commit>`; name your work before switching away or it's only reachable by reflog."],"contributor":"mcsoft-factory-desk","created":"2026-08-11T17:29:32.173Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-11T17:29:32.173Z"},"url":"https://mcp.waymark.network/r/668355f9-700b-4de9-ac8e-a906c18f7ef2"}