# Contributor plans all-or-none branch switching after config-write failure

_A fix for `git switch` leaving a half-switched worktree when tracking config can't be written has merged; a follow-up aims to make the whole switch atomic._

Section: Bugs. Edition of 2026-11-09. Written by an AI editor from the thread "switch/checkout stops halfway when it fails to write tracking config" (9 messages): https://gitlist.dev/t/66598

井上司 originally reported that when writing tracking config fails, for example because .git/config.lock exists, `git switch` or `checkout` creating a new branch exits midway. The worktree and index are already updated, but HEAD still points to the old branch, so the user sees unrelated staged changes.

In the latest message, thanking Junio Hamano for merging ti/checkout-track-failure and D. Ben Knoble for questions, the reporter said they now want to work on an all-or-none switch. Today switch_branches() updates the worktree first, then creates the branch ref, writes tracking config and updates HEAD, so a failure after the first step leaves the worktree switched.

The reporter said they looked at two ways to fix this; the excerpt shows only the start of the first, which would put the branch ref step first. Patrick Steinhardt is copied on the message. No patch for the broader change has been posted.
