Subject: Re: [PATCH] checkout: add --autostash option for branch switching

From: Junio C Hamano <[email-masked]>
Date: Thu, 19 Mar 2026 09:48:47 -0700

Harald Nordgren <[email-masked]> writes:

> Hi Junio and Jeff!
>
> Did you get a chance to look at the latest changes?
>
> The scope of this grew a lot from my original idea of auto-stashing, so I'm
> not 100% convinced that changing '-m' is necessary here. My fear is to
> break something, especially since 'checkout -m' is a feature I never used
> before touching it here, so I don't have a good sense of how it should
> work.

FWIW, I very much like what I see in 

   $ git checkout hn/git-checkout-m-with-stash && git diff @{1}

output.  It is great that we do not have to do any dry-run, because
the "real" run safely aborts, we can do the "stash && merge && unstash"
dance as a fallback instead.  All the credit goes to Phillip and you
for the idea and the execution of this.

I do use "checkout -m" a few times a week, but I do not do anything
complex with submodules or run the command with unrelated local
modifications, so there may be changes in behaviour I haven't seen
in corner cases that I do not exercise.