Tortoise SVN merge two branches
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
.
- In TortoiseSVN, click on
Merge
option and then selectMerge two different trees
option. - In the
From URL
, please mention URL of branchA
and in theTo URL
, mention URL of branchB
.
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 frombranch1
.
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:
- Checkout
branch2
- Merge
branch1
intobranch2
and commit those changes.branch2
will have all the changes inbranch1
. - Checkout
trunk
- Merge
branch2
intotrunk
. Trunk will now have all the changes in bothbranch1
andbranch2
.