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

Re: [BUG?] git checkout -b removes MERGE_HEAD

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 18, 2010, 18:39 UTC
Message-ID
<7vwroabhng.fsf@alter.siamese.dyndns.org>
In-Reply-To
<456aec650e66bba518b8a5ec88c88a6b.squirrel@artax.karlin.mff.cuni.cz>
"Jan Hudec" <bulb@ucw.cz> writes:
Show 11 quoted lines
>  - During the testing I found a problem, but it may have already
>    existed on master before the merge.
>  - Therefore I needed to return to clean master, test it and return
>    to the merge. So I thought I'd commit the merge to a temporary
>    branch, test master again and merge the temporary to master if
>    the problem is not from the merge. So I did:
>
>    $ git checkout -b temp
>    $ git commit
>
>    OOPS! It forgot it was a merge.

I think it was an oversight by the author of 91dcdfd (Make "git checkout" create new branches on demand, 2005-07-11) who forgot that he also did ef0bfa2 (Remove MERGE_HEAD in "git checkout/reset", 2005-06-21). The rationale for the removal of MERGE_HEAD from the earlier commit is:

    [this command] will end up resetting the index to some specific
    head, and any unresolved merge will be forgotten [hence there is no
    point recording the result as a merge].
but when used with -b no such "resetting of the index" happens.

Having said that, changing it not to remove MERGE_HEAD and MERGE_MSG is probably not sufficient, as MERGE_MSG would likely to already record to which branch you are recording the merge (I didn't check, though).

Previous: Jan HudecNext: Jan Hudec
Message 2 of 4 in “[BUG?] git checkout -b removes MERGE_HEAD”
  1. Jan HudecNov 18, 2010
  2. Junio C HamanoNov 18, 2010
  3. Jan HudecNov 18, 2010
  4. Jeff KingNov 18, 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.