summaryrefslogtreecommitdiffstats
path: root/gitk-git
diff options
context:
space:
mode:
authorHarald Nordgren <haraldnordgren@gmail.com>2026-04-28 18:39:12 +0000
committerJunio C Hamano <gitster@pobox.com>2026-04-29 21:46:03 +0900
commitc07039ebc4bbf2eb6c852fb1280891a448d1bf48 (patch)
treeb57e9940626b24c3a2e9b233ae12ea259cd46c15 /gitk-git
parent26e4e50d463e1427c6288b33054e5d9a4a99a8f0 (diff)
downloadgit-c07039ebc4bbf2eb6c852fb1280891a448d1bf48.tar.gz
git-c07039ebc4bbf2eb6c852fb1280891a448d1bf48.zip
checkout -m: autostash when switching branches
When switching branches with "git checkout -m", the attempted merge of local modifications may cause conflicts with the changes made on the other branch, which the user may not want to (or may not be able to) resolve right now. Because there is no easy way to recover from this situation, we discouraged users from using "checkout -m" unless they are certain their changes are trivial and within their ability to resolve conflicts. Teach the -m flow to create a temporary stash before switching and reapply it after. On success, the stash is silently applied and the list of locally modified paths is shown, same as a successful "git checkout" without "-m". If reapplying causes conflicts, the stash is kept and the user is told they can resolve and run "git stash drop", or run "git reset --hard" and later "git stash pop" to recover their changes. Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitk-git')
0 files changed, 0 insertions, 0 deletions