From: Junio C Hamano Date: Thu, 12 Mar 2026 19:50:10 GMT Subject: Re: [PATCH v2] checkout: add --autostash option for branch switching Message-ID: In-Reply-To: "Harald Nordgren via GitGitGadget" writes: > From: Harald Nordgren > > When switching branches, local modifications in the working tree can > prevent the checkout from succeeding. While "git rebase" and "git > merge" already support --autostash to handle this case automatically, > "git checkout" and "git switch" require users to manually stash and > unstash their changes. > > Teach "git checkout" and "git switch" to accept --autostash and > --no-autostash options that automatically create a temporary stash > entry before the branch switch begins and apply it after the switch > completes. If the stash application results in conflicts, the stash > entry is saved to the stash list so the user can resolve them later. > > Also add a checkout.autoStash configuration option that enables this > behavior by default, which can be overridden with --no-autostash on > the command line. With this, shouldn't "-m" become a synonym for "--autostash"? For users of "checkout -m", this is a strictly improved version of the same feature, it seems. Also, "stash" is merely an implementation detail of how we make the merge safer, so from end-user's point of view, this feature is more like "switch to the other branch, while merging the local changes there", so calling it "--merge" or something may be much better than calling it "--autostash". Other than that, I like the implementation in general.