If you'd rather use the TortoiseSVN client for Windows as your Subversion client of choice, this video will walk you through the process of taking an existing project folder on your local workstation and creating a Subversion project with it, and also pulling an existing Subversion project down to your local workstation to create a working copy.
- [Presenter] We'll connect to a project one more time, but this time we'll use the TortoiseSvn program on a Windows. First we'll start with a project that's already on our local work station and we want to upload it as a new project to the subversion server. We'll navigate to the local project folder in Windows Explorer. If you want to follow along this will be exercise files, zero three underscore zero five, start. Within the start folder there's a folder called tortoise project and that folder has a few files in it. Right click the tortoise project folder and choose TortoiseSvn, repo-browser.
You can see there's actually an import option here too, but in this case it's actually easier to use the repo-browser directly. We need an url and we can get that from our VisualSVN server. I'll switch to the VisualSVN server management console, right click the repository, and choose copy url to clipboard. In TortioseSVN, I can paste that url and click ok. In the repo-browser, I can right click the repository and create a new folder for my project.
Right click, create folder, and I'll give it a name of tortoise project. Click ok and we get prompted to add a comment about what we're doing. So I'm going to say we're creating the tortoise project folder, creating tortoise project folder and click ok. Now I want to create a trunk folder beneath the project folder, it's the same process.
Right click the new tortoise project, create folder and the folder name will be trunk. I'll leave a commit comment, creating tortoise project trunk and click ok. So here's the tricky part, back in Windows Explorer right click the local project and choose the SVN checkout option.
What we're doing here is checking out the new trunk folder from SVN into the local folder that contains all of our project files. I know that seems kind of weird but with TortoiseSVN that's actually the easiest way to do it. This is referred to as in the TortoiseSVn help as the import and place process. So the repository url in this case isn't just the repository, it's the full path to the project directory you're checking out. This is different from Eclipse, so be sure you're pointing to the right place. It says url of repository in the dialogue, but it really means url to project.
I can find the project by clicking this button and browsing to tortoise project and trunk, and clicking ok. Now if I expand the dialogue I can see that my checkout directory is exercise files, zero three zero five, start, tortoise project, but it added on an extra tortoise project here at the end. I don't want that. I'm going to get rid of it. So we're checking out directly to this tortoise project folder. Everything else we can leave as default and I'll click ok.
TortoiseSVN will warn you that your local folder isn't empty. In this case that's fine, so click checkout to finish the process. If we look at the folder again in Windows Explorer, we'll see that there's now a hidden dot SVN folder in our local project directory. At this point we have a local project folder that's associated with an empty subversion project. The next step is to tell SVN we have some files to add. Go back up one directory, right click our project folder, and choose TortoiseSVN from the context menu.
Since this folder is now a local working copy and not just a regular file folder, you'll see a lot more options than the TortoiseSVN menu. Choose the option for add. This opens a dialogue that allows you to choose files and folders from inside the local folder. Choose all the items you want to add to the SVN project, in this case it's everything and click ok. We see a list of all the files that got added and a message telling us the process is complete. You'll notice that it didn't prompt us for a commit comment, which might seem weird because I've been telling you to add a commit comment to everything you do with SVN.
Well, why didn't we get prompted for a comment? We haven't actually added anything new to the server yet. That SVN add command that just happened only told the local working copy that it has new files. We checked out an empty project before and now we're saying that the project should have these new files in it. In other words, we changed the local configuration of the project. So the next step is to commit these local changes to the server. Right click the local project folder in Windows Explorer again and choose the SVN commit menu option.
Now we're prompted for a commit message since we're actually sending information to the server. So I'll tell SVN that this commit involves adding some files to the project, initial commit of tortoise project to trunk. Also notice that we don't have to include all the new or changed files with this commit. You can uncheck some of the files or folders and do a partial commit if you want. This is handy if you've made a large number of changes and you want to split the commit into separate parts.
Or maybe you made some changes to the project configuration files that you don't want to save. In any case, we want to commit all of our changes, so all the boxes are checked, we can click ok. We get a list of all the files that got committed, a completed message that tells us that everything was successful and the new revision number of our project, revision nine. It may seem strange that the revision number is so high, since we started with an empty project and this is the first change we've ever made to that project, why isn't the revision number one or two? This is because the subversion server uses the same incremental revision number counter for every project and folder in the repository.
Since we've got other projects in this repository that have already been changed, the revision number for all projects has been incremented several times. Don't let this bother you. You really should ignore revision numbers because they're just a placeholder for the server. SVN will sort everything out project by project for you when you need it to. The other scenario to talk about here is pulling down an existing project from SVN to create a brand new local working copy. That's really easy. Just create a new folder on your work station.
I'll right click, choose new folder and call it new folder. Right click the folder and choose SVN checkout. Point to the url of the project folder you want to check out. Even though it says url of repository here, you really want the url of the folder that you were checking out. We'll do a fully recursive checkout here and we'll get the head revision, since we want the full project and the latest and greatest version of the code.
Then we can just click ok. Now a familiar dialogue appears telling us all the things that happened and we can click ok again because we're done. That's it. If you open up new folder, you see that it has a new dot SVN hidden folder, so this is a new working copy. We now have a local working copy we can change and sync with the server.
- 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