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

Counter-intuitive results for git show and git checkout during rebase with conflict.

From
Nazri Ramliy <ayiehere@gmail.com>
Date
Feb 23, 2009, 04:04 UTC
Message-ID
<544dda350902222004v742a7175od19ac417f75ddd1a@mail.gmail.com>

The scenario: We have two branches, local and master, we are now on branch local, and we would like to rebase local wrt master:

	% git rebase master
	conflictedfile: needs merge
	cannot rebase: you have unstaged changes

Obviously we have a conflict, here's the problem: these commands have counter-intuitive effect (as oppose to during a git merge with conflict):

  git show :2:conflictedfile  # shows content from master version
  git show :3:conflictedfile  # shows content from local version
  git checkout --ours conflictedfile   # gets content from master version
  git checkout --theirs conflictedfile # gets content from local version

I know why they are counter-intuitive - :2:, :3:, --ours and --theirs are relative to the current <commit>, and during a conflict due to a rebase, the current <commit> is some commit that leads to master, which is not anywhere in the path that leads to local.

So in summary:
Fact 1:
  During a conflict due to a rebase, HEAD is a commit that leads to
  the other branch.
Fact 2:
  During a conflict due to a merge, HEAD is a commit that leads to the
  current branch.
(Please correct me if the two facts above are not true)

Technically there's nothing wrong with the behavior of the commands, but wouldn't it be better if the arguments :2:conflictedfile and :3:conflictedfile to git show and the options --ours and --theirs to git checkout be made aware of the two facts above and do a more intuitive action?

Or should this be left to a higher level tools to automatically detect the reason of the conflict and adjust the arguments appropriately so that the end results are intuitive for the user?

nazri.
Next: Jay Soffian
Message 1 of 2 in “Counter-intuitive results for git show and git checkout during rebase with conflict.”
  1. Nazri RamliyFeb 23, 2009
  2. Jay SoffianFeb 23, 2009

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.