Re: [PATCH 0/5] Advice on checkout dirty files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 10, 2026, 13:36 UTC
- Message-ID
- <xmqqzf4fx0vo.fsf@gitster.g>
- In-Reply-To
- <5f100fe0-d601-4ee3-adb9-a2458203d10d@gmail.com>
Phillip Wood <phillip.wood123@gmail.com> writes:
> If the intent is for the user to carry over the changes to the new > branch then recommending "git checkout -m" might be more convenient > rather than having to stash, checkout and unstash as three separate steps.
I personally would not recommend pushing "-m" to new people without explaining its ramifications, though.
If "git stash pop" fails while a commit different from the original is checked out, the working tree will get conflicts for you to resolve, and that is the same as "git checkout -m". But the conflict may turn out to be too complex that you might not be able to cleanly resolve.
With a "git stash pop" that gets interrupted by a conflict, the stash entry is not removed from the stash, so there is a clean recourse to "git reset --hard" away the conflict and attempting to unstash (either to the same commit or to a different base).
With "git checkout -m", on the other hand, there is no such recourse. The conflicted working tree with the unmerged index is all you get, and you get only a single chance to resolve it correctly.
So...