Re: Q: rebasing (moving) a whole tree (not just one branch)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]