Saturday, September 12, 2009

Subversion Basics In Xcode

My last post discussed how to set up Xcode to use Subversion via Beanstalk. Now let's take a look at some common activities.

Editing Files



This is easy enough... make some changes to a file, then save it.



The SCM column will provide status information when appropriate for each file. In this case, 'M' is shown, indicating that the file has been modified. You could see any number of M's, depending on how many files you change between commits (more on commit in a moment). See the Apple documentation for a complete list of possible symbols.

Adding Files



Whether you create a new file inside your project, or add existing files from elsewhere, the end result is the same:



The SCM column will display a '?', and as seen from the help pop-up, that means the status is unknown. This indicates that the file is not yet in the repository - it is in your local project only.

To indicate that you would like to add these files to your repository, right-click on any appropriate files, and choose 'Add to Repository'.



The '?' will change to an 'A'.



This indicates that the file will be added to the repository during the next commit.

Committing Changes



I am more accustomed to "check in" terminology, but a commit is exactly the same thing. Local changes will be uploaded to the repository.

Go to the SCM menu, and choose 'Commit Entire Project...'.



I believe you can do commits on individual files, but I haven't had much of a reason to do so. I pretty much always commit the entire project.

Xcode will present a dialog box allowing you to enter notes related to this commit.



Once you are done, the M's and A's should all be gone, indicating the files are now in the repository.

How often you commit is up to you. I personally attempt to do so at minimum nightly for any files that I work on. If I achieve some major milestone earlier in the day, I'll send up an extra commit.

Updating Files



If other people share your repository, or if you access it from multiple computers, you will probably see this at some point:



The U indicates that the file in the repository is newer than your local file, and it needs to be updated. As a convenience, Xcode will repeat the status indicator on the group folder, just in case you are not displaying all files at the moment.

You can either right-click on individual files and update...



...or you can update the entire project.



And this concludes what I know about Subversion. Hopefully these two posts will get you off to a good start. Enjoy.

1 comment:

Baris said...

Helped a lot, thanks!
And I had tried several tutorials before this, to no avail.