git merge commits staged files (when two trees are identical)
- From
Andreas Krey <a.krey@gmx.de>
- Date
- Dec 20, 2017, 11:43 UTC
- Message-ID
- <20171220114310.GA2049@inner.h.apk.li>
Hi everybody,
we just stumbled over a situation in which a merge commits staged changes into the merge commit. This happens when the merged-in branch does have commits ('main') but has the same tree ('--allow-empty') as the merge base:
git init
echo eins >a
git add a
git commit -m initial
git branch sub
git commit -m main --allow-empty
git checkout sub
: two
echo zwei >>a
git add a
git commit -m underway
: three
echo drei >>a
git add a # important
git status
git diff --cached
git merge master -m 'merge'
git status
git log --cc -1If the change isn't staged (comment out the '# important' line) the change survives as unstaged.
That is a bug?
- Andreas
-- "Totally trivial. Famous last words." From: Linus Torvalds <torvalds@*.org> Date: Fri, 22 Jan 2010 07:29:21 -0800