git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Apply commits from one branch to another branch (tree structure is different)
@ 2014-03-14 17:39 Jagan Teki
  2014-03-14 18:11 ` Jagan Teki
                   ` (2 more replies)
  0 siblings, 3 replies; 9+ messages in thread
From: Jagan Teki @ 2014-03-14 17:39 UTC (permalink / raw
  To: git; +Cc: Brandon McCaig

Hi,

I have two branch in one repo that I need to maintain for 2 different
deliveries.
Say branch1 and branch2 in test.git repo.

test.git
- branch1
     foo_v1/text.txt
     foo_v2/text.txt
- branch2
     foo/text.txt

branch1 is developers branch all source looks version'ed manner and
branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories
in branch1 where developer will update the latest one here foo_v2 and branch2
foo is same as the latest one of branch1 for an instance.

Suppose developer send 10 patches on branch1 where are changes in terms
of <dir>_<version>/ then I need to apply on my local repo branch1, till now
is fine then I need to apply same 10 patches on to my branch2 where source
tree <dir> which is quite question here how can I do.

Request for any help! let me know for any questions.


thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 17:39 Apply commits from one branch to another branch (tree structure is different) Jagan Teki
@ 2014-03-14 18:11 ` Jagan Teki
  2014-03-18 17:11   ` Brandon McCaig
  2014-03-14 19:18 ` Andrew Wong
  2014-03-18 17:18 ` Brandon McCaig
  2 siblings, 1 reply; 9+ messages in thread
From: Jagan Teki @ 2014-03-14 18:11 UTC (permalink / raw
  To: git; +Cc: Brandon McCaig

Don't know what happen, I'm unable to join #git channel
[23:40] <Jagan> hi
[23:40] == Cannot send to channel: #git

Can any one help!

On Fri, Mar 14, 2014 at 11:09 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Hi,
>
> I have two branch in one repo that I need to maintain for 2 different
> deliveries.
> Say branch1 and branch2 in test.git repo.
>
> test.git
> - branch1
>      foo_v1/text.txt
>      foo_v2/text.txt
> - branch2
>      foo/text.txt
>
> branch1 is developers branch all source looks version'ed manner and
> branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories
> in branch1 where developer will update the latest one here foo_v2 and branch2
> foo is same as the latest one of branch1 for an instance.
>
> Suppose developer send 10 patches on branch1 where are changes in terms
> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
> is fine then I need to apply same 10 patches on to my branch2 where source
> tree <dir> which is quite question here how can I do.
>
> Request for any help! let me know for any questions.
>
>
> thanks!
> --
> Jagan.



-- 
Jagan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 17:39 Apply commits from one branch to another branch (tree structure is different) Jagan Teki
  2014-03-14 18:11 ` Jagan Teki
@ 2014-03-14 19:18 ` Andrew Wong
  2014-03-14 20:01   ` Jagan Teki
  2014-03-18 17:18 ` Brandon McCaig
  2 siblings, 1 reply; 9+ messages in thread
From: Andrew Wong @ 2014-03-14 19:18 UTC (permalink / raw
  To: Jagan Teki; +Cc: Git List, Brandon McCaig

On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Suppose developer send 10 patches on branch1 where are changes in terms
> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
> is fine then I need to apply same 10 patches on to my branch2 where source
> tree <dir> which is quite question here how can I do.

You might be able to use the subtree option in recursive merge. Try
something like:

    git cherry-pick -X subtree=foo <commit>

This tells git to apply the changes to the "foo" directory in your
current branch (branch2).

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 19:18 ` Andrew Wong
@ 2014-03-14 20:01   ` Jagan Teki
  2014-03-14 20:37     ` Andrew Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Jagan Teki @ 2014-03-14 20:01 UTC (permalink / raw
  To: Andrew Wong; +Cc: Git List, Brandon McCaig

On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:
> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
>> Suppose developer send 10 patches on branch1 where are changes in terms
>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
>> is fine then I need to apply same 10 patches on to my branch2 where source
>> tree <dir> which is quite question here how can I do.
>
> You might be able to use the subtree option in recursive merge. Try
> something like:
>
>     git cherry-pick -X subtree=foo <commit>
>
> This tells git to apply the changes to the "foo" directory in your
> current branch (branch2).

How do I do this?

Suppose I'm in branch1 with two commits on foo_v2 and I need to apply them
on branch2 where in foo.

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 20:01   ` Jagan Teki
@ 2014-03-14 20:37     ` Andrew Wong
  2014-03-14 20:57       ` Jagan Teki
  0 siblings, 1 reply; 9+ messages in thread
From: Andrew Wong @ 2014-03-14 20:37 UTC (permalink / raw
  To: Jagan Teki; +Cc: Git List, Brandon McCaig

On Fri, Mar 14, 2014 at 4:01 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:
>> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
>>> Suppose developer send 10 patches on branch1 where are changes in terms
>>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
>>> is fine then I need to apply same 10 patches on to my branch2 where source
>>> tree <dir> which is quite question here how can I do.
>>
>> You might be able to use the subtree option in recursive merge. Try
>> something like:
>>
>>     git cherry-pick -X subtree=foo <commit>
>>
>> This tells git to apply the changes to the "foo" directory in your
>> current branch (branch2).
>
> How do I do this?
>
> Suppose I'm in branch1 with two commits on foo_v2 and I need to apply them
> on branch2 where in foo.

Since this uses cherry-pick, the changes that you want to apply have
to be on branch1 already.

Let's say your branch1 looks like:
    --A--B--C--D
and branch2 looks like:
    --1--2--3--4

And you want to apply commits B and C on branch2, but they modify
"foo_v1/" on branch1. You can tell git to apply the commits onto the
directory "foo/" on branch2:
    git checkout branch2    # make sure you're on branch2
    git cherry-pick -X subtree=foo B C    # pick the commits

If there's no conflict, the commits should apply cleanly, and your
branch2 would become like:
    --1--2--3--4--B'--C'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 20:37     ` Andrew Wong
@ 2014-03-14 20:57       ` Jagan Teki
  2014-03-14 21:57         ` Andrew Wong
  0 siblings, 1 reply; 9+ messages in thread
From: Jagan Teki @ 2014-03-14 20:57 UTC (permalink / raw
  To: Andrew Wong; +Cc: Git List, Brandon McCaig

On Sat, Mar 15, 2014 at 2:07 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:
> On Fri, Mar 14, 2014 at 4:01 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
>> On Sat, Mar 15, 2014 at 12:48 AM, Andrew Wong <andrew.kw.w@gmail.com> wrote:
>>> On Fri, Mar 14, 2014 at 1:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
>>>> Suppose developer send 10 patches on branch1 where are changes in terms
>>>> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
>>>> is fine then I need to apply same 10 patches on to my branch2 where source
>>>> tree <dir> which is quite question here how can I do.
>>>
>>> You might be able to use the subtree option in recursive merge. Try
>>> something like:
>>>
>>>     git cherry-pick -X subtree=foo <commit>
>>>
>>> This tells git to apply the changes to the "foo" directory in your
>>> current branch (branch2).
>>
>> How do I do this?
>>
>> Suppose I'm in branch1 with two commits on foo_v2 and I need to apply them
>> on branch2 where in foo.
>
> Since this uses cherry-pick, the changes that you want to apply have
> to be on branch1 already.
>
> Let's say your branch1 looks like:
>     --A--B--C--D
> and branch2 looks like:
>     --1--2--3--4
>
> And you want to apply commits B and C on branch2, but they modify
> "foo_v1/" on branch1. You can tell git to apply the commits onto the
> directory "foo/" on branch2:
>     git checkout branch2    # make sure you're on branch2
>     git cherry-pick -X subtree=foo B C    # pick the commits
>
> If there's no conflict, the commits should apply cleanly, and your
> branch2 would become like:
>     --1--2--3--4--B'--C'

I created two commits on foo_v2 when I move branch2 and
did cherry-pick it shows below:

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")

thanks!
-- 
Jagan.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 20:57       ` Jagan Teki
@ 2014-03-14 21:57         ` Andrew Wong
  0 siblings, 0 replies; 9+ messages in thread
From: Andrew Wong @ 2014-03-14 21:57 UTC (permalink / raw
  To: Jagan Teki; +Cc: Git List, Brandon McCaig

On Fri, Mar 14, 2014 at 4:57 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> 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.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 18:11 ` Jagan Teki
@ 2014-03-18 17:11   ` Brandon McCaig
  0 siblings, 0 replies; 9+ messages in thread
From: Brandon McCaig @ 2014-03-18 17:11 UTC (permalink / raw
  To: Jagan Teki; +Cc: git

Jagan:

On Fri, Mar 14, 2014 at 1:11 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Don't know what happen, I'm unable to join #git channel
> [23:40] <Jagan> hi
> [23:40] == Cannot send to channel: #git

I'm not sure if this is the problem that you were having, but #git on
freenode is NickServ protected. You need to register with NickServ (a
bot on the network) and identify yourself with it in order to be
allowed to speak in #git. This cuts down on spam. You can `/msg
NickServ help' to learn how to use it (and also Google will be your
friend).

Alternatively, check the channel topic for an alternative solution.

Regards,


-- 
Brandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: Apply commits from one branch to another branch (tree structure is different)
  2014-03-14 17:39 Apply commits from one branch to another branch (tree structure is different) Jagan Teki
  2014-03-14 18:11 ` Jagan Teki
  2014-03-14 19:18 ` Andrew Wong
@ 2014-03-18 17:18 ` Brandon McCaig
  2 siblings, 0 replies; 9+ messages in thread
From: Brandon McCaig @ 2014-03-18 17:18 UTC (permalink / raw
  To: Jagan Teki; +Cc: git

Jagan:

On Fri, Mar 14, 2014 at 12:39 PM, Jagan Teki <jagannadh.teki@gmail.com> wrote:
> Hi,

Hello,

> I have two branch in one repo that I need to maintain for 2 different
> deliveries.
> Say branch1 and branch2 in test.git repo.
>
> test.git
> - branch1
>      foo_v1/text.txt
>      foo_v2/text.txt
> - branch2
>      foo/text.txt
>
> branch1 is developers branch all source looks version'ed manner and
> branch2 is superset for branch1, example foo_v1 and foo_v2 are the directories
> in branch1 where developer will update the latest one here foo_v2 and branch2
> foo is same as the latest one of branch1 for an instance.
>
> Suppose developer send 10 patches on branch1 where are changes in terms
> of <dir>_<version>/ then I need to apply on my local repo branch1, till now
> is fine then I need to apply same 10 patches on to my branch2 where source
> tree <dir> which is quite question here how can I do.
>
> Request for any help! let me know for any questions.

This just sounds like a painful workflow to me. I would suggest not
doing this at all, but rather using tags to mark specific releases,
and using individual branches for continued development (e.g., stable
or v1.x or whatever is most appropriate). You can have unstable or
master or dev or whatever for developers to work on freely without
breaking releases (albeit, there are many different workflows you can
use to manage the transition from unstable to stable code).

I would avoid using subtrees (subdirectories) within a Git repository
to represent different releases of the code. Git already tracks
versions. That is redundant and messy. It's really an outdated way of
thinking about version control.

/my 2 cents

Regards,


-- 
Brandon McCaig <bamccaig@gmail.com> <bamccaig@castopulence.org>
Castopulence Software <https://www.castopulence.org/>
Blog <http://www.bamccaig.com/>
perl -E '$_=q{V zrna gur orfg jvgu jung V fnl. }.
q{Vg qbrfa'\''g nyjnlf fbhaq gung jnl.};
tr/A-Ma-mN-Zn-z/N-Zn-zA-Ma-m/;say'

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-03-18 17:18 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14 17:39 Apply commits from one branch to another branch (tree structure is different) Jagan Teki
2014-03-14 18:11 ` Jagan Teki
2014-03-18 17:11   ` Brandon McCaig
2014-03-14 19:18 ` Andrew Wong
2014-03-14 20:01   ` Jagan Teki
2014-03-14 20:37     ` Andrew Wong
2014-03-14 20:57       ` Jagan Teki
2014-03-14 21:57         ` Andrew Wong
2014-03-18 17:18 ` Brandon McCaig

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).