Posts tagged with: source-control

Subversion: Merging a Branch to Trunk

Merging a Subversion Branch Back to Trunk

So, you’ve successfully branched code and have a great new feature set you need to get back to trunk, but how? Easy!

Get the latest revision number of the branch you want to merge

If you already have the branch checked out, cd to that directory and svn update it.

Alternatively, if you don’t have (or don’t want to have) the branch checked out locally, you can do it remotely.

The last line returned contains the first revision of that branch, it’ll look something like this:

Check out trunk

Alternatively, you can just update trunk if you have it checked out

Change to the trunk working directory and do the following:

You should see output like this:

This will update your copy of trunk to the most recent version and tell you the revision you are at. Make note of that number as well (should say “At revision YYYY”; where YYYY is the second number you’ll need to remember).

Perform the merge

Now you’ve got the details you need; the revision at which the branch started and the most current revision.

Change directory to the trunk

Check in the results:

Final thoughts

Described above is how to perform the act of merging a branch back to the trunk, there are however many things I didn’t cover. Before you perform this operation you should do a review of all the changes and potential conflicts if the trunk was also receiving active development.

In a team environment, this would be a great time for a peer/mentor code review as well as an approach review for the bugs/featured covered in the branch.