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

A bug in git merge

From
Orgad Shaneh <orgads@gmail.com>
Date
Mar 27, 2018, 09:53 UTC
Message-ID
<CAGHpTBJ-4a5+5=303_N-n3TtUg_sXt6J1cad0WCQ4Kc-=HDdSA@mail.gmail.com>
Hi,

If I cherry-pick a commit that added a line, then merge another commit which removes this line, the line remains in the file instead of being removed.

The following script demonstrates the bug.
file should be equivalent on both branches

git init seq 1 20 > file git add file git commit -m 'Initial' sed -i "s/^5/5\n55/" file git commit -a -m 'Added 55' git checkout -b other HEAD^ git cherry-pick master git commit --amend --author 'Author <a@b.c>' --no-edit # generate a new hash sed -i '/55/d' file git commit -a -m 'Removed 55' git checkout master git merge --no-edit other git diff other # Should be equal

- Orgad
Next: Jeff King
Message 1 of 2 in “A bug in git merge”
  1. Orgad ShanehMar 27, 2018
  2. Jeff KingMar 27, 2018

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.