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

Re: Interpreting git merge failures

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2011, 16:40 UTC
Message-ID
<7vy6038nb6.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CAKmUPx5Qt2K+7F+BsW3WTmRjodBSrteuyG8p9oRHZuhApTu4+g@mail.gmail.com>
Scott Bronson <bronson@rinspin.com> writes:
> What is the best way to determine why a git merge failed?
If you get exit code 0, the merge did not fail.
Otherwise you can inspect the index after getting the non-zero exit code.

If you have an unmerged entry in the index, there could be two cases. The most typical is that the merge was attempted and stopped due to an conflict. "ls-files -u" will show these paths. Another is a user error to run "git merge" when your index is already unmerged, but you can easily avoid this at the beginning of your script, stopping without running "git merge" when the index is unmerged to begin with.

If you do not have an unmerged entry in the index, the merge refrained from overwriting either your local modifications in the working tree, or your local modifications to the index. Again the latter is a user error that you can detect before running "git merge" in your script.

Previous: Jeff King
Message 3 of 3 in “Interpreting git merge failures”
  1. Scott BronsonJul 7, 2011
  2. Jeff KingJul 12, 2011
  3. Junio C HamanoJul 12, 2011

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.