Setting up SubVersion (SVN) on Local Ubuntu with Netbeans

Assuming you have SVN installed follow these steps from the shell (where “proj” is your project). You can put this anywhere you want really, this is how I decided to do it though to keep it out of my default apache directory. I’ll show steps for configuring this to work with apache if you’re doing this as a PHP repo on your localhost. You may need to sudo yourself for these commands. Also, I’m an SVN novice so follow at your own risk. I’m pretty sure I did this poorly…

Next import any existing files into SVN.  Even if I don’t have any pre-existing code I do this step anyways.  If you have any files or directories you want to keep out of the SVN repository (environmental configs, frameworks, logs etc.) then withhold them from the import and add them manually later.  When you end up adding these files later, use the NetBeans GUI to set them to ignore otherwise you will  have to go through the SVN command line using propset.

The last thing we will want to do is create a directory outside of SVN to checkout the files too and do all our actual work in.  I choose to put this in /var/www/svncheckout/proj.

I’ve included a screenshot of the steps I took right on my Ubuntu 10.10. desktop.  You can even see the dumb little mistakes I made in there, doh!

Create svn repo share from ubuntu linux shell

The NetBeans Side of Things

In NetBeans perform the following steps.

  1. Create a new project (File -> New Project).  Select your options, I chose PHP and PHP Application with Existing Sources.  Click Next.
  2. Enter in the sources folder /var/www/svncheckout/proj and a project name. Check Next.
  3. The next window asks you to enter in the project url.  Enter in the url you intend on using for the project on your local machine. Click finish.
  4. Checkout the files from SVN by click in Team -> Subversion -> Checkout in the NetBeans menu.
  5. Enter in the repository url, file:///var/svn/proj and Click Next.
  6. Browser the repository folders and select the trunk of your project. Clock OK.
  7. You just want to checkout the trunks contents so check the Skip option and also check the Export a clean directory option.  Make sure you’ve specificied a local folder to checkout to such as /var/www/svncheckout/proj

Here are some screenshots I took of the process:

Creating new project

Creating a netbeans project

Entering sources

Adding sources to netbeans project

SVN File Checkout

SVN file checkout with netbeans

SVN file checkout with netbeans step 2

SVN file checkout with netbeans step 3

Subversion Cheat Sheet
Ubuntu Doc. on Subversion
Netbeans Doc. on Subversion

Now onto the Apache portion cause if you’re like me this is going to be a LAMP project. This is a simple change to /etc/apache2/sites-available/default and a restart of apache. Simply add this to the bottom of the file. Don’t add within an existing virtual host, cause its kind of its own deal.

Restart apache! One last thing now. Your machine doesn’t really know what proj.localhost is and neither do any DNS servers. So edit your hosts file /etc/hosts and simply add in a line like this:

Okay now we’re really done. Drop me a comment if this helped your or if you feel I missed something, thanks for reading.

** update **

This blog was featured in the Net Beans newsletter…sweet! Love Net Beans!

This blog post has been updated since its original posting.  Last updated February 19, 2011.


3 Comments

1 Trackback