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

The case of `git update-ref MERGE_HEAD`

From
Johannes Sixt <j6t@kdbg.org>
Date
Sep 12, 2025, 16:19 UTC
Message-ID
<c9794ca2-0822-485f-a10f-6ecefa7275d1@kdbg.org>
When I commit a merge, the commit message shows this advice:

# It looks like you may be committing a merge. # If this is not correct, please run # git update-ref -d MERGE_HEAD # and try again.

However, when I follow the advice, I get this error:

$ git update-ref -d MERGE_HEAD error: refusing to update pseudoref 'MERGE_HEAD'

Also, I found a use case to set MERGE_HEAD to a particular commit, but I can't do that, either:

$ git update-ref MERGE_HEAD e9c115e666fd6a3faaf187f5d145b32861a45cc8 fatal: update_ref failed for ref 'MERGE_HEAD': refusing to update pseudoref 'MERGE_HEAD'

I know I can do
$ echo e9c115e666fd6a3faaf187f5d145b32861a45cc8 > .git/MERGE_HEAD

in the primary worktree. But I needed to do this in a secondary worktree, where this is more like

$ echo e9c115e666fd6a3faaf187f5d145b32861a45cc8 \
     > "$(git rev-parse --git-dir)"/MERGE_HEAD
which is a bit unwieldy...

8e4f5c2dc26e ("refs: refuse to write pseudorefs", 2024-05-15) removed the ability to wrangle pseudo-refs with `git update-ref`. Much earlier, b6d2558c9ea3 ("builtin/commit: suggest update-ref for pseudoref removal", 2020-08-21) changed the commit message template with the justification:

> [S]uggest a "update-ref -d" command, which will work regardless of
> ref storage backend.
Looks like we couldn't uphold the promise. Any suggestions?
-- Hannes
Next: Patrick Steinhardt
Message 1 of 2 in “The case of `git update-ref MERGE_HEAD`”
  1. Johannes SixtSep 12, 2025
  2. Patrick SteinhardtSep 15, 2025

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.