Re: [PATCH] checkout: add --autostash option for branch switching
- From
Harald Nordgren <haraldnordgren@gmail.com>
- Date
- Apr 9, 2026, 12:06 UTC
- Message-ID
- <20260409120631.12207-1-haraldnordgren@gmail.com>
- In-Reply-To
- <20260331121633.14907-1-haraldnordgren@gmail.com>
Show 18 quoted lines
>> 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.
>
> I wonder if my implementation is not really up to par. I have ran into a
> few "conflicts", were 'git stash pop' simply worked afterwards.
>
> So not quite production ready.Update on this: I realized that the issues I ran into was happening because of a sub-shell, so it's resolved by running like this:
export GIT_EXEC_PATH=/Users/Harald/git-repos/github.com/git/git && \
/Users/Harald/git-repos/github.com/git/git/git checkout -m -So thus, it's not a real problem.
I think this is ready to be reviewed, does anyone have time to take a look?
Harald