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 itAnd then run "git cherry-pick --continue" to continue with the cherry-pick.