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

Re: Apply commits from one branch to another branch (tree structure is different)

From
Andrew Wong <andrew.kw.w@gmail.com>
Date
Mar 14, 2014, 21:57 UTC
Message-ID
<CADgNjan7iDOgzXd4Ue69tM9CztM8OmHqzD6yEW7e6v8oM_yBxQ@mail.gmail.com>
In-Reply-To
<CAD6G_RTzbJGc10doV_ZbC5bd=Zpr6rPbNXni+Yo7cxD38DCLMQ@mail.gmail.com>
On Fri, Mar 14, 2014 at 4:57 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
Show 17 quoted lines
> Mr.J> git cherry-pick -X subtree=foo
> cc70089614de16b46c08f32ea61c972fea2132ce
> 14e9c9b20e3bf914f6a38ec720896b3d67f94c90
> error: could not apply cc70089... AAAAAAAAAAAAAAAAA
> hint: after resolving the conflicts, mark the corrected paths
> hint: with 'git add <paths>' or 'git rm <paths>'
> hint: and commit the result with 'git commit'
> Mr.J> ls
> foo
> Mr.J> gs
> # On branch branch2
> # Unmerged paths:
> #   (use "git add/rm <file>..." as appropriate to mark resolution)
> #
> #    deleted by us:      foo/foo_v2/test.txt
> #
> no changes added to commit (use "git add" and/or "git commit -a")

Does the foo_v2/test.txt file already exist in branch2 before you try to apply? i.e. does foo/test.txt exist in branch2?

What might be happening is: the commit modifies foo_v2/test.txt on branch1, but foo/test.txt doesn't exist on branch2. So even when you use the subtree option, there's no foo/test.txt on branch2 to "receive" the changes of foo_v2/test.txt. This is an actual conflict that git doesn't know what to do, so you have resolve it. This probably means one of two things for you:

1. You _want_ foo/test.txt on branch2, then:
        git add foo/foo_v2/test.txt    # get the entire test.txt file
from that commit on branch1
        git mv foo/foo_v2/test.txt foo/test.txt    # move/rename the
file to the right location
2. You _don't_ want foo/test.txt on branch2, then:
        git rm foo/foo_v2/test.txt    # just remove it
And then run "git cherry-pick --continue" to continue with the cherry-pick.
Previous: Jagan TekiNext: Brandon McCaig
Message 8 of 9 in “Apply commits from one branch to another branch (tree structure is different)”
  1. Jagan TekiMar 14, 2014
  2. Jagan TekiMar 14, 2014
  3. Brandon McCaigMar 18, 2014
  4. Andrew WongMar 14, 2014
  5. Jagan TekiMar 14, 2014
  6. Andrew WongMar 14, 2014
  7. Jagan TekiMar 14, 2014
  8. Andrew WongMar 14, 2014
  9. Brandon McCaigMar 18, 2014

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.