threads / discuss / 42591

merge committing staged deletions?

Subject: merge committing staged deletions?

## tl;dr

One message between Jun 16, 2016 and Jun 16, 2016.

replies: 0people: 1as markdown or json

Joey Hess· Jun 13, 2016, 18:13 UTC · lore

I have a case where git merge seems to include staged deletions into the merge commit. This seems pretty surprising, dunno if it's a bug.

joey@darkstar:~/tmp/x/1>git rm 1 foo
joey@darkstar:~/tmp/x/1>git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)
	deleted:    1
	deleted:    foo
joey@darkstar:~/tmp/x/1>git merge refs/heads/synced/master --no-ff
Already up-to-date!
Merge made by the 'recursive' strategy.
 1   | 1 -
 foo | 1 -
 2 files changed, 2 deletions(-)
 delete mode 100644 1
 delete mode 100644 foo

I thought that a merge would leave staged changes alone, unless they conflict in some way with the changes merged in. So why is merge looking at the staged deletions in this case?

I'm using --no-ff because the commit being merged is itself a merge of HEAD and another commit. HEAD and the commit being merged in fact have the same tree, so the right merge solution, AFAICS, would be to keep that tree.

I've attached a 1 kb git bundle that you can clone to reproduce this:
	git clone bundle b
	cd b
	git rm 1
	git merge remotes/origin/synced/master --no-ff
git version 2.8.1
-- 
see shy jo

← back to recent threads