From: Harald Nordgren via GitGitGadget Date: Sun, 15 Mar 2026 11:19:09 GMT Subject: [PATCH v5 0/4] checkout: 'autostash' for branch switching Message-ID: In-Reply-To: cc: Phillip Wood phillip.wood123@gmail.com Harald Nordgren (4): stash: add --ours-label, --theirs-label, --base-label for apply sequencer: allow create_autostash to run silently sequencer: teach autostash apply to take optional conflict marker labels checkout: -m (--merge) uses autostash when switching branches Documentation/git-checkout.adoc | 58 +++++----- Documentation/git-stash.adoc | 11 +- Documentation/git-switch.adoc | 27 ++--- builtin/checkout.c | 180 ++++++++++++++++++-------------- builtin/stash.c | 32 ++++-- sequencer.c | 67 +++++++++--- sequencer.h | 4 + t/t3420-rebase-autostash.sh | 24 +++-- t/t3903-stash.sh | 18 ++++ t/t7201-co.sh | 160 ++++++++++++++++++++++++++++ t/t7600-merge.sh | 2 +- xdiff-interface.c | 12 +++ xdiff-interface.h | 1 + 13 files changed, 447 insertions(+), 149 deletions(-) base-commit: dc6ecd5354dca88d51b6d6562777fc8fc10d77e1 Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2234%2FHaraldNordgren%2Fcheckout_autostash-v5 Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2234/HaraldNordgren/checkout_autostash-v5 Pull-Request: https://github.com/git/git/pull/2234 Range-diff vs v4: -: ---------- > 1: 00d8920498 stash: add --ours-label, --theirs-label, --base-label for apply -: ---------- > 2: 5d176f1700 sequencer: allow create_autostash to run silently -: ---------- > 3: 3d6829438a sequencer: teach autostash apply to take optional conflict marker labels 1: 5d49c0031a ! 4: 7f3735d40e checkout: -m (--merge) uses autostash when switching branches @@ Documentation/git-checkout.adoc: working tree, by copying them from elsewhere, e + afterwards. If the local changes do not overlap with the + differences between branches, the switch proceeds without + stashing. If reapplying the stash results in conflicts, the -+ entry is saved to the stash list so you can use `git stash -+ pop` to recover and `git stash drop` when done. ++ entry is saved to the stash list. Resolve the conflicts ++ and run `git stash drop` when done, or clear the working ++ tree (e.g. with `git reset --hard`) before running `git stash ++ pop` later to re-apply your changes. + When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths. This option cannot be @@ Documentation/git-checkout.adoc: $ git checkout mytopic -You can give the `-m` flag to the command, which would try a -three-way merge: -+You can give the `-m` flag to the command, which would save the local -+changes in a stash entry and reset the working tree to allow switching: ++You can give the `-m` flag to the command, which would carry your local ++changes to the new branch: ------------ $ git checkout -m mytopic -Auto-merging frotz -+Applied autostash. ++Switched to branch 'mytopic' ------------ -After this three-way merge, the local modifications are _not_ @@ Documentation/git-switch.adoc: variable. + local changes do not overlap with the differences between + branches, the switch proceeds without stashing. If + reapplying the stash results in conflicts, the entry is -+ saved to the stash list so you can use `git stash pop` to -+ recover and `git stash drop` when done. ++ saved to the stash list. Resolve the conflicts and run ++ `git stash drop` when done, or clear the working tree ++ (e.g. with `git reset --hard`) before running `git stash pop` ++ later to re-apply your changes. `--conflict=