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

Re: preventing evil merges

From
Antoine Pelisse <apelisse@gmail.com>
Date
Jun 3, 2013, 17:37 UTC
Message-ID
<CALWbr2yLHN7VgPhH-HvyBx04pHasH=zr6fTXtjjsKJgqHA8kKQ@mail.gmail.com>
In-Reply-To
<7vvc5vglh5.fsf@alter.siamese.dyndns.org>
On Mon, Jun 3, 2013 at 7:20 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 26 quoted lines
> Sandro Santilli <strk@keybit.net> writes:
>
>>  git merge anotherbranch
>>  git add something
>>  git commit --amend
>>
>> After the steps above the addition of "something" can't be found in
>> the history anymore, but the file is there.
>
> This is a very common and sensible thing to do when dealing with
> semantic conflict.  Imagine that you changed the name of a global
> variable in the code on your current branch since the anotherbranch
> you are pulling from forked from you.  Then imagine further that the
> anotherbranch added one location that refers to that variable.
>
> Since they are not aware of the name change, they added the new
> reference with the old variable name.  The part they added is a new
> code, so it is very likely that there is no textual conflict when
> you did "git merge anotherbranch".  But now the result is broken.
>
> And you fix that semantic conflict by editing the file they added
> the new reference to the variable under the old name and make it use
> the variable with the new name.  You "git add something" and amend
> the merge.
>
> "git show" of the result will show you what happened, I think.

Also, you need to use --cc option of log to see the change in history (in addition to -p):

    git log --cc -p
Previous: Junio C Hamano
Message 3 of 3 in “preventing evil merges”
  1. Sandro SantilliMay 30, 2013
  2. Junio C HamanoJun 3, 2013
  3. Antoine PelisseJun 3, 2013

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.