* Q: rebasing (moving) a whole tree (not just one branch)
@ 2011-03-18 20:05 Dirk Süsserott
2011-03-18 20:26 ` Jonathan Nieder
0 siblings, 1 reply; 5+ messages in thread
From: Dirk Süsserott @ 2011-03-18 20:05 UTC (permalink / raw)
To: Git Mailing List
Hi,
I'd like to rebase a whole tree from A to B. Not just a single branch,
but a whole tree. Let's say I have the following history:
--- A --- B
|
+ -- C -- D
|
+ E -- F
I'd like to rebase C and its descendants from A to B so it becomes:
--- A --- B
|
+ -- C' -- D'
|
+ E' -- F'
I know I can do it manually with
git rebase B C
git rebase C D
git rebase C E
git rebase E F
Is there a way to just say "rebase C and all after that from A to B"?
Dirk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q: rebasing (moving) a whole tree (not just one branch)
2011-03-18 20:05 Q: rebasing (moving) a whole tree (not just one branch) Dirk Süsserott
@ 2011-03-18 20:26 ` Jonathan Nieder
2011-03-18 21:14 ` Junio C Hamano
0 siblings, 1 reply; 5+ messages in thread
From: Jonathan Nieder @ 2011-03-18 20:26 UTC (permalink / raw)
To: Dirk Süsserott; +Cc: Git Mailing List
Hi Dirk,
Dirk Süsserott wrote:
> I'd like to rebase a whole tree from A to B. Not just a single
> branch, but a whole tree. Let's say I have the following history:
>
> --- A --- B
> |
> + -- C -- D
> |
> + E -- F
>
> I'd like to rebase C and its descendants from A to B
I'd suggest cheating by making a merge of D and F and "rebase -p"-ing
that. :)
To say something more sensible would probably require more information
about the particular application, though.
Hope that helps,
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q: rebasing (moving) a whole tree (not just one branch)
2011-03-18 20:26 ` Jonathan Nieder
@ 2011-03-18 21:14 ` Junio C Hamano
2011-03-18 21:34 ` Jonathan Nieder
2011-03-18 22:53 ` Johannes Sixt
0 siblings, 2 replies; 5+ messages in thread
From: Junio C Hamano @ 2011-03-18 21:14 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: Dirk Süsserott, Git Mailing List
Jonathan Nieder <jrnieder@gmail.com> writes:
> Dirk Süsserott wrote:
>
>> I'd like to rebase a whole tree from A to B. Not just a single
>> branch, but a whole tree. Let's say I have the following history:
>>
>> --- A --- B
>> |
>> + -- C -- D
>> |
>> + E -- F
>>
>> I'd like to rebase C and its descendants from A to B
>
> I'd suggest cheating by making a merge of D and F and "rebase -p"-ing
> that. :)
>
> To say something more sensible would probably require more information
> about the particular application, though.
I am not a huge fan of filter-branch, but shouldn't you be able to
filter-branch D and F (and no other branch) on top of B?
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q: rebasing (moving) a whole tree (not just one branch)
2011-03-18 21:14 ` Junio C Hamano
@ 2011-03-18 21:34 ` Jonathan Nieder
2011-03-18 22:53 ` Johannes Sixt
1 sibling, 0 replies; 5+ messages in thread
From: Jonathan Nieder @ 2011-03-18 21:34 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Dirk Süsserott, Git Mailing List
Junio C Hamano wrote:
>> Dirk Süsserott wrote:
>>> I'd like to rebase a whole tree from A to B. Not just a single
>>> branch, but a whole tree. Let's say I have the following history:
>>>
>>> --- A --- B
>>> |
>>> + -- C -- D
>>> |
>>> + E -- F
>>>
>>> I'd like to rebase C and its descendants from A to B
[...]
> I am not a huge fan of filter-branch, but shouldn't you be able to
> filter-branch D and F (and no other branch) on top of B?
Yes, something like
git filter-branch \
--commit-filter '
if test "$GIT_COMMIT" = '"$(git rev-parse A^{commit})"'
then
git rev-parse B^{commit}
else
git_commit_non_empty_tree "$@"
fi
' \
--index-filter '
if test -n "$(git rev-list -1 "$GIT_COMMIT"..A)"
then
# descends from A
git merge-recursive A -- "$GIT_COMMIT" B
fi
' -- --all --not A^
might do it, assuming the diff from A to B is simple enough for a
fully automatic rebase.
But in practice, something may well be much better. It depends why we
are performing this mass-rebasing --- do A and B have the same content
in the moment and different histories? How did the topics we are
rebasing get tangled, and is their history going to remain meaningful
after this operation?
Jonathan
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Q: rebasing (moving) a whole tree (not just one branch)
2011-03-18 21:14 ` Junio C Hamano
2011-03-18 21:34 ` Jonathan Nieder
@ 2011-03-18 22:53 ` Johannes Sixt
1 sibling, 0 replies; 5+ messages in thread
From: Johannes Sixt @ 2011-03-18 22:53 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jonathan Nieder, Dirk Süsserott, Git Mailing List
On Freitag, 18. März 2011, Junio C Hamano wrote:
> Jonathan Nieder <jrnieder@gmail.com> writes:
> > Dirk Süsserott wrote:
> >> I'd like to rebase a whole tree from A to B. Not just a single
> >> branch, but a whole tree. Let's say I have the following history:
> >>
> >> --- A --- B
> >>
> >> + -- C -- D
> >>
> >> + E -- F
> >>
> >> I'd like to rebase C and its descendants from A to B
> >
> > I'd suggest cheating by making a merge of D and F and "rebase -p"-ing
> > that. :)
> >
> > To say something more sensible would probably require more information
> > about the particular application, though.
>
> I am not a huge fan of filter-branch, but shouldn't you be able to
> filter-branch D and F (and no other branch) on top of B?
Not in a trival way. You would need a tree-filter that re-applies the change
between A and B to every transcribed commit. That will work well only if
there are no conflicts.
-- Hannes
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2011-03-18 22:53 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-18 20:05 Q: rebasing (moving) a whole tree (not just one branch) Dirk Süsserott
2011-03-18 20:26 ` Jonathan Nieder
2011-03-18 21:14 ` Junio C Hamano
2011-03-18 21:34 ` Jonathan Nieder
2011-03-18 22:53 ` Johannes Sixt
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 NNTP newsgroup(s).