On Sat, Sep 04, 2021 at 11:51:19AM +0200, Fedor Biryukov wrote: > There is no way this could be the intended behavior, but the good news > is that I cannot reproduce it... > Looks like it occurs only in one git version (2.31.0.windows.1, IIRC). > And it does not occur in the latest git version: git version 2.33.0.windows.2. I think it is a bug, and it seems to reproduce easily for me (with both the current tip of master, and with v2.33.0). Here's the recipe you showed, with a little debugging at the end: set -x git init repo cd repo git commit -m base --allow-empty git checkout -b feat echo feat >readme.txt git add readme.txt git commit -m txt=feat git checkout main echo precious >readme.txt cat readme.txt git checkout feat cat readme.txt git rebase main feat cat readme.txt This produces: + cat readme.txt precious + git checkout feat error: The following untracked working tree files would be overwritten by checkout: readme.txt Please move or remove them before you switch branches. Aborting + cat readme.txt precious + git rebase main feat Current branch feat is up to date. + cat readme.txt feat So git-checkout was not willing to overwrite the untracked content, but rebase was happy to obliterate it. It does the right thing in very old versions. Bisecting, it looks like the problem arrived in 5541bd5b8f (rebase: default to using the builtin rebase, 2018-08-08). So the bug is in the conversion from the legacy shell script to C (which makes sense; the shell version was just calling "git checkout", which we know does the right thing). -Peff