If a change you're making to a Subversion/SVN project is big enough, or experimental enough, you might want to create a new branch for working on your changes, to keep it separate from the primary development trunk. In this video you can talk about how to create new branches using Eclipse, and how to switch your working copy to use a branch.
- [Narrator] So far, we've been doing all our work in trunk. That's fine and some people stay in trunk and never leave, but most people use some sort of branching strategy to work on branches separate from trunk, so they can merge their changes back in later, or so they can abandon their changes if they don't work. Let's make a branch and see what that process looks like. We're starting from the Eclipse project, we used in the previous section, that's already connected to the SVN server. Right-click this project in Package Explorer, and choose Team, Branch.
One thing that might trip you up here, up until now we've been entering full URLs to point to repositories and projects on the Subversion server, but the Eclipse Subversive plug-in is kind of smart, and it knows that when we say we want to make a branch, that means we want to create a folder in the branch's folder of the current project. It already knows what project we're in and it knows that the branch's folder is, or will be, called Branches. So you don't need any of that up here. For the branch name, you literally just enter the name of the branch, not the full URL.
Keep in mind that this specific shortcut, it's functionality, this builds in to the Eclipse Subversive plug-in. So if you're using a different plug-in, like Subclips, you might have slightly different options, like you might have to enter a full URL here. But if you do use the Subversive plug-in, this is all you have to do. I'll use GlazedDonutRecipe for my branch name because I'll be working on a new class that makes a glazed donut. Some organizations have standards for branch names. They might include a version number or a reference change control system, or something.
If your team has branch name standards, use those, otherwise, use something short and descriptive. You can even have subfolders in your branch's folder, if you're really super organized. Below the branch name, I'm going to check the Start working in the branch option, because I not only want to create the branch, I actually want to use it right away, too. And I should write a comment about what I'm doing because adding a branch will cause a new revision to be added to the Subversion server, creating GlazedDonut branch.
Another interesting point to mention, we have the option to use working copy as it is, beneath the branch name. This means that if we made changes to our local working copy that were out of sync with the server, that's okay. All of our local changes will be part of a new branch. This is a pretty handy option in some situations. For example, let's say you've been working on code from trunk, and after a few hours you say, oh man, I really should of created a branch for this. No problem, just create a branch with the, Use working copy as is, option, and all your changes will end up there, instead of in trunk.
Piece of cake. After you click Okay, the new branch has been created, and our local working copy of code is now pointing to the branch. You can see the branch name right next to the Subversion URL at the top of the project. If you had the SVN console open and active, you'll also see all the commands that were used to create the branch. I'll maximize that window so we can look. We've got a Copy command, to copy our local working directory files to the branch, and then a Switch command, to switch the working copy from trunk, where we were before, over to the new branch.
Just to confirm that all this happened the way we expected, let's switch over to the Subversion server and refresh the repository. (clicking) Under ProjectDonut, branches, we can see our new GlazedDonutRecipe branch, with all of our files. That's our new branch.
- Trunks, tags, and branches
- Checkout, commits, and revisions
- Merging, locking, and working with a team
- TortoiseSVN on Windows
- SVN integration with Eclipse
- Connecting to a project
- Creating a new Java project in Eclipse
- Connecting to an existing Java project using Eclipse
- Dealing with projects that move to a new location
- Making changes and creating branches
- Tracking changes and dealing with conflicts
- Creating a release