Subversion Merge: Merging your working branch back into the trunk.

[Updated 2015-02-02]

Purpose of this post:

To demonstrate how and why to merge a branched project under Subversion Source Control back with it’s root project.  The documentation provided with TortoiseSVN, while extensive, is confusing and vague.  Many of the actions described both in the documentation and in the TortoiseSVN GUI are not clear whether they are acting on the local drive or on the server.  The terminology is inconsistent.  This post makes it clear.

[GARD]

Intended Audience:

Programmers new or somewhat new to Subversion Version Control System.

Target Platform and Tools:

This will be on a Windows client platform (server platform is not relevant to this discussion) using the TortoiseSVN Windows Shell extension (It adds a right-click menu to folders in Windows Explorer).

Expectations of the reader:

It’s assumed that the reader:

  • has already downloaded and installed TortoiseSVN.
  • has access to a Subversion server.
  • Can perform basic operations on Subversion with TortoiseSVN.
  • understands the basic concepts of version or source control (repository, check in (commit), check out (update), etc…)
  • is a programmer or system administrator.
  • is reading this post to learn how to perform a merge operation on a Windows client with TortoiseSVN to a Subversion trunk.
  • has a folder somewhere on their hard drive with source files in it that are already being controlled by Subversion.
  • Has already performed a branch, is working with the branch, and now would like to merge that branch back to the server folder from which it was originally branched.
What this post does NOT do:
  • Teach you about the basics of version control (or source control).
  • Teach you how to install any components of any software.
  • anything other than provide what you need to know to perform a merge operation.
  • talk about any particular programming language.
  • try to convince you that Subversion is better or worse than any other version control system.
What is “Merging”?

For the purposes of this discussion, “Merging” is the act of getting a branched copy of a project on the Subversion server to merge back into the original folder on the server from which it was originally branched.

How to Merge:

[GARD]

  1. From your local, working folder that’s linked to your branched project on the Subversion folder, perform a commit to get all your changes checked back into your branched copy on the server.
  2. Do an update to ensure your local, working copy has the latest files from the branched copy on the server.
  3. If you don’t already have a local folder that is linked to your Subversion server’s trunk folder of your project (or the original server folder from which your branch was originally branched), then make a new, local folder and link that to your Subversion server’s trunk folder.  (You will be performing the merge from the local working copy of the server’s trunk folder).
  4. Right-click your local, working folder that’s linked to your server’s trunk folder and choose TortoiseSVN, Merge.
  5. Choose “Merge a range of revisions”. image
  6. Click “Next”.
  7. In the text box “URL to merge from”, make sure your server’s branched folder is entered.
  8. Click “Show Log” and select all versions (not just the latest), then “OK”.
  9. Put a check mark next to each version in your branch that needs to be merged to the trunk (any version # that’s greater than whatever version # you branched from the trunk).
  10. Click “Next”.
  11. Click “Merge”.
  12. Wait for it to complete, then click “OK”.
  13. This merged the branched copy in the server to your local working copy of your trunk folder.  It’s still not yet on the server’s trunk folder.  Rick-click your local working copy of your trunk and choose “Commit” to push all the changes up to the server’s trunk folder.
  14. Do an “Update” on your local working folder that’s linked to your server’s trunk folder to ensure you have all the latest code (not just the latest from the old branched copy).
  15. Delete your branched folder on the server if you’re done with it.
  16. Delete your local working branch folder too, if you’re done with it (You should now be working with your local working copy of the server’s trunk folder).

[GARD]

That’s it.  Your local working copy and your server’s trunk folder now have the latest changes from your branch.

Related articles (articles that aren’t links have not yet been written):

Subversion Branch: How To

Purpose of this post:

To demonstrate how and why to branch a project under Subversion Source Control.  The documentation provided with TortoiseSVN, while extensive, is confusing and vague.  Many of the actions described both in the documentation and in the TortoiseSVN GUI are not clear whether they are acting on the local drive or on the server.  The terminology is inconsistent.  This post makes it clear.

Intended Audience:

Programmers new or somewhat new to Subversion Version Control System.

Target Platform and Tools:

This will be on a Windows client platform (server platform is not relevant to this discussion) using the TortoiseSVN Windows Shell extension (It adds a right-click menu to folders in Windows Explorer).

Expectations of the reader:

It’s assumed that the reader:

  • has already downloaded and installed TortoiseSVN.
  • has access to a Subversion server.
  • Can perform basic operations on Subversion with TortoiseSVN.
  • understands the basic concepts of version or source control (repository, check in (commit), check out (update), etc…)
  • is a programmer or system administrator.
  • is reading this post to learn how to perform a branch operation on a Windows client with TortoiseSVN to a Subversion server.
  • has a folder somewhere on their hard drive with source files in it that are already being controlled by Subversion.
What this post does NOT do:
  • Teach you about the basics of version control (or source control).
  • Teach you how to install any components of any software.
  • anything other than provide what you need to know to perform a branch operation.
  • talk about any particular programming language.
  • try to convince you that Subversion is better or worse than any other version control system.
What is “Branching”?

Branching is when you have a project in a version control system and you want to split off (or clone) a copy of it and work with that copy, making changes (commits) to it over time.  At some later point, you may (or may not) decide to merge those changes back into the main (trunk or head) project.

Part of the “Best Practices” of Subversion usage is to always create a branch when you start working on a new feature or version of a product.  When you’re done, you then merge your branched copy back into the main copy, then delete your branch.

How to branch:
  1. Make sure your server project has a trunk folder and a branches folder.
  2. Starting with your local copy, commit (takes your local changes and uploads them to the server) all of your changes now (It’s important that your local copy and your server copy are both up to date).  This local copy should be linked to your trunk folder (or whatever server folder you want to branch from).
  3. Now, do an “update” (which gets the latest version from the server).
  4. Right-click your local folder, choose “TortoiseSVN”, then “Branch/Tag”
  5. In the “To URL” text box, you should see the current server folder that your local folder is linked to.  Change it to the new (yet to exist) branch folder you want your branched copy to exist in on the server.  In other words, in that text box, delete the work “trunk” and type the word “branches/” then the name of the branched copy.  This will cause a new folder to be created in the server repository under the “branches” folder.
  6. In the lower left, check the box “Switch working copy to new branch/tag”.  This will cause your local folder that you’re working from to be unlinked from the trunk folder from the server and then linked to the new branched copy on the server.  All future commits will go to the branched copy on the server and all updates to that local copy will come from the branched folder on the server.
  7. Click “OK”.

You will now have a new subfolder on the server repository under your branches folder on the server.  Your local copy is no longer linked to your server’s trunk folder.  It’s now linked to your newly created subfolder in the repository under the branches folder on the server.

If you now make changes to your local copy, then commit, your changes will be submitted to your branched copy on the server.  The trunk folder on the server will not receive your commits.  Further, any updates (downloading from the server) will come from your newly created folder on the server under the server’s branches folder.

Related articles (articles that aren’t links have not yet been written):