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.
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:
- 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.
- Do an update to ensure your local, working copy has the latest files from the branched copy on the server.
- 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).
- Right-click your local, working folder that’s linked to your server’s trunk folder and choose TortoiseSVN, Merge.
- Choose “Merge a range of revisions”.
- Click “Next”.
- In the text box “URL to merge from”, make sure your server’s branched folder is entered.
- Click “Show Log” and select all versions (not just the latest), then “OK”.
- 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).
- Click “Next”.
- Click “Merge”.
- Wait for it to complete, then click “OK”.
- 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.
- 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).
- Delete your branched folder on the server if you’re done with it.
- 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).
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: Linking a local folder to a Subversion folder on the server.
Subversion: Checking out.
Subversion: Checking in.