Mac Subversion Tutorial
I started out using Subversion in an office where somebody else had set up a repository and trac and taken care of all the dity work. It was remarkably easy for me to get started. I found the world of version control so appealing and in fact, indispensable, that I quickly decided I wanted to get this working on my machines at home. Learning Rails also made it necessary - I spent so many frustrating hours trying to figure this out and felt like I would never make any progress. I read a ton of tutorials and nothing was working. I tried installing MAS and was baffled. I tried working with opensvn and after some intital success I was still confused and crying tears of rage.
Finally it clicked into place and I felt like I should share my own method which seemed remarkably easy considering the frustrating path I had taken to get there.
First install Martin Ott’s Subversion package:
Unzip and run it. Done. You won’t see any fireworks - but you will now have command line access to Subversion available in Terminal from /usr/local/bin.
To use Subversion commands from anywhere in your Terminal command line, add Subversion to your path:
- Open Terminal from Applications/Utilities
- Create a new text file called bash_profile:
pico .bash_profile
- Add the following line to the file
export PATH=/usr/local/bin:$PATH
- Hit Control-X, then confirm the file save with Y and then hit return
- Let Terminal read this file to know the path has changed:
. .bash_profile
Now create your first repository:
svnadmin create yourRepNameHere
This will get created in the current directory (For those unfamiliar with Unix, you can change directories with cd and list directories with ls)
Now you can move into svnx and this is where things get remarkably easy.
svnX
svnx is a GUI for Subversion that will make life much easier and keep you away from hacking away in Terminal as much as possible:
http://www.lachoseinteractive.net/en/community/subversion/svnx/download/
This will install an app you can open like any other Mac app.
Under Window/Repositories , hit the plus sign to create a new repo link, give it a name, then click on the magnifying glass to browse for your repository
Double click on the repository to open it.
First you’ll want click svn mkdir to create an initial directory.
Now select that directory from the columns at the bottom of the repository window.
Click svn checkout.
Pick or create a detination folder for a working copy - this is the folder of files that you will be editing and working with - the original repository folder shouldn’t be touched.
Now you have checked out a working copy for youself.
You can go to the Mac Finder and throw some files in there.
Now back in svnX go to Window/Working Copies and you’ll find that svnX has added the copy you checked out to your list of working copies.
Double click on the working copy to open it.
Click refresh to see what has changed in your working copy.
You’ll see the files you have added to the working copy folder.
You can choose to add them to the repository.
Now that they have been added you’ll want to comit the change to actually finiazlie the addition to your source repository.
Now the file has been added and committed to the original repository.
Now you can go and edit those files you’ve just added, save the changes.
Go back to your working copy and refresh again.
You’ll see that it has notes the edits you’ve made.
Happy with those edits? Commit them to finalize the edits you’ve made into the source repository.
That’s the end of my humble tutorial but just the beginning with Subversion - there’s lots of other stuff to learn about subversion, and I have barely scratched the surface.
For example - and this is one of the main benefits of using Subversion - you can have many people working on the same files at the same time. they can each commit the changes they have made and subversion will keep track of everything so no changes get lost, if the edits that are being done are in conflict subversion will let you figure out how to resolve the problem.
Another useful thing that can be done with Subversion is once you’ve finished one release of your project you can leave that as is and then when you’re ready to begin working on 2.0 you can create a duplicate so that if the project goes astray down the line - the original 1.0 release can remain unharmed.
There’s also Subversion on the web - web hosts are increasingly supporting Subversion, Ruby on Rails people and Rails plugins in particular are largely dependent upon Subversion.
you can also get access to free Subversion server hosting opensvn.csie.org is one such example. I found it confusing at best but if you can get it working you’ll get free trac as well which is like a wiki to your project and really helps you keep track of edits and whatnot.
Subversion is a powerful tool and I hope this tutorial has helped you begin to reap the benefits without too many tears or foul-mouthed diatribes.