git/list[1] front-page[2] threads[3] people[4] search[5] about
 

merge committing staged deletions?

From
Joey Hess <id@joeyh.name>
Date
Jun 13, 2016, 18:13 UTC
Message-ID
<20160613181308.GA31546@kitenet.net>

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
Message 1 of 1 in “merge committing staged deletions?”
  1. Joey HessJun 13, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.