i'm trying to merge two branches with tortoise SVN. Both branches have been changed since they diverged. If i merge them, only the changes of one of them obtain and those of the other will be overwritten. But i want the latest change of every file (We have not been working in the same files).
I tried the option "Merge two different trees" and entered the two branches in "From:" and "To:". I took the Head Revision on both. I left everything else to default (Merge depth: Working Copy, Compare whitespaces, everything else unchecked)
Basically that means a temporary clone of the (feature) branch is created, a sync merge is made from the parent branch to the temporary branch, and finally the parent branch is replaced by the temporary branch. In other words, the temporary branch contains all changes made to the (feature) branch and parent branch.
In the From URL
option, you should specify the branch to which you want to merge.
For example, assume that there are 2 branches, branch A
and branch B
, and you want to merge branch B
to branch A
.
Merge
option and then select Merge two
different trees
option. From URL
, please mention URL of
branch A
and in the To URL
, mention URL of branch B
.This should merge branch B
to branch A
without losing any files.
Reference: found this statement here
Merging in Subversion is always done locally. The branch you want to merge to should be checked out with a clean checkout. That is, it should be up to date with no local changes. You then merge the other branch into it and commit your changes.
A Merge is not a duplicate of a particular branch. Merging is usually a three way operation. You have the branch you're merging into (called yours) the branch you're merging from (called theirs), and the last common ancestor (LCA). That last one is important.
If a change took place on your branch, it's not touched during the merge process. The merge algorithm knows this because there's a difference between yours and the LCA. If there is difference between the LCA and theirs, that's considered for a change.
If I understand you have:
branch1
was taken from trunk.branch2
was taken from branch1
.What are you trying to merge? Do you want to merge both branch1
and branch2
into trunk. This should be possible if you copied trunk
into branch1
through Subversion and copied branch1
into branch2
through Subversion. This way, Subversion knows that the two branches are related in their history.
If you created the branch, used Windows to copy the files, and added the files, you have no history between the two branches, and merging is more difficult.
Is it okay to merge the changes of branch2
into branch1
? If so, I'd do something like this:
branch2
branch1
into branch2
and commit those changes. branch2
will have all the changes in branch1
.trunk
branch2
into trunk
. Trunk will now have all the changes in both branch1
and branch2
."Merge two different trees" option is useful when you're trying to make one branch look exactly like another branch.
If instead you want your output branch to contain changes from both the branches, you should use the "Merge a range of revisions" option.
Steps to use the Merge a range of revisions option:
Note: output branch
refers to the branch you want to merge your changes into.
While input branch
refers to the branch whose changes you want to merge in the output branch
output branch
input branch
input branch
. If you want to merge specific revisions only, select 'specific range' and use the 'Show log' button to choose the revisions. TortoiseSVN is smart in this regard, and any revision that has already been merged will be greyed out and marked with an Already merged iconoutput branch
For further details refer to TortoiseSVN Docs on Merging
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With