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

Re: Branch merge bug

From
Michael J Gruber <git@drmicha.warpmail.net>
Date
Jan 19, 2010, 12:07 UTC
Message-ID
<4B55A080.7010705@drmicha.warpmail.net>
In-Reply-To
<f3271551001182322p86a02d8p8b9ceb49e930d333@mail.gmail.com>
Ramkumar Ramachandra venit, vidit, dixit 19.01.2010 08:22:
> A friend showed me this reduced test case. It seems to work fine with
> bzr and hg. Is this a git bug?

It's not a bug, it's a feature. Git does not track renames. It tracks content and detects renames when necessary. Knowing that it is easy to construct examples on which git merge "fails", such as the one you present.

A file which is changed completely is not a renamed file, it's a new one under the same name. Whether the committer meant to create a new file (using the same name by accident or on purpose) or whether it is really a heavily modified and renamed version - who knows? Git doesn't, and cannot, and it leaves that decision up to you.

If you really mean to modify and rename an existing file, then tell Git so:

git mv fil fila git commit -m 'we need a new name'

instead of your 'git rm fil' will record your intentions (not only for Git, but also for everyone else reading your log, such as you a year from now) and will make the merge succeed.

Michael
Previous: Ramkumar RamachandraNext: Andreas Krey
Message 2 of 5 in “Branch merge bug”
  1. Ramkumar RamachandraJan 19, 2010
  2. Michael J GruberJan 19, 2010
  3. Andreas KreyJan 19, 2010
  4. Ramkumar RamachandraJan 19, 2010
  5. Michael J GruberJan 19, 2010

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.