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

Re: git add -p and unresolved conflicts

From
HHHolger Hellmuth <hellmuth@ira.uka.de>
Date
Mar 28, 2012, 22:50 UTC
Message-ID
<4F7395B6.1020506@ira.uka.de>
In-Reply-To
<7vvclotpp7.fsf@alter.siamese.dyndns.org>
Am 28.03.2012 22:50, schrieb Junio C Hamano:
Show 10 quoted lines
> I think Matthieu is not thinking about the "resolve conflicted merge (or
> rebase, am) and make a single commit" use case, for which your "pick one
> of the sides" makes sense.  His is more about "I like some change in that
> unrelated commit---while I have no intention to replay that change as a
> whole, I want to use "cherry-pick --no-commit" and pick only the bits out
> of the change that are useful for what I am doing" use case.
>
> In such a context, after resolving conflicts in the working tree, "add -p"
> would be a good tool to pick hunks in the diff between the HEAD and the
> working tree.

Ok. Something like this (which is not really that different from Eriks example, so I might still be missing something) ?

git init . echo "foo" > bar.txt git add bar.txt git commit -m. git checkout -b new echo "bar" >> bar.txt git commit -am. git checkout master git reset --hard echo "baz" >> bar.txt git commit -am. git cherry-pick --no-commit new git add -p bar.txt

So he would be interested in keeping his previous working tree version (identical to HEAD commit, otherwise cherry-pick fails) for conflicting chunks as they (in most cases) don't have anything to do with the chunks he is interested in. In this case that is "baz"

Which would always be the "ours" side in any conflicting junks.

That suggests that he could just type '<' respective 'o' whenever a conflicting junk comes up as it would be the previous working tree version

Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 21 in “git add -p and unresolved conflicts”
  1. Erik Faye-LundMar 28, 2012
  2. Junio C HamanoMar 28, 2012
  3. Matthieu MoyMar 28, 2012
  4. Holger HellmuthMar 28, 2012
  5. Junio C HamanoMar 28, 2012
  6. Holger HellmuthMar 28, 2012
  7. Jeff KingMar 29, 2012
  8. Holger HellmuthMar 29, 2012
  9. Matthieu MoyMar 28, 2012
  10. Junio C HamanoMar 28, 2012
  11. Holger HellmuthMar 28, 2012
  12. Junio C HamanoMar 28, 2012
  13. Holger HellmuthMar 28, 2012
  14. Junio C HamanoMar 28, 2012
  15. Junio C HamanoMar 28, 2012
  16. Holger HellmuthMar 29, 2012
  17. Matthieu MoyMar 29, 2012
  18. Junio C HamanoMar 29, 2012
  19. Matthieu MoyMar 30, 2012
  20. Erik Faye-LundMar 28, 2012
  21. Junio C HamanoMar 28, 2012

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.