Recent site activity

Source Control Management Systems


Install Git

OSX comes with an installed version of Git if you have installed XCode. But as usual the Apple version is a very old version of Git. To have a current version of Git we can use the Git OSX installer hosted on google code. The installer installs all Git tools under /usr/local/bin/git. The Git coming with OSX is installed under /usr/bin.To eliminate problem with the OSX version of Git you should delete the Git tools under /usr/bin and create the following links.
cd /usr/bin
sudo ln -s /usr/local/git/bin/git git
sudo ln -s /usr/local/git/bin/git-cvsserver git-cvsserver
sudo ln -s /usr/local/git/bin/git-receive-pack git-receive-pack
sudo ln -s /usr/local/git/bin/git-shell git-shell
sudo ln -s /usr/local/git/bin/git-upload-archive git-upload-archive
sudo ln -s /usr/local/git/bin/git-upload-pack git-upload-pack
sudo ln -s /usr/local/git/bin/gitk gitk

The configuration of Apache to service Git requests is documented here.
A better approach is to use gitolite if you have to administrate multiple projects and teams. How to install and configure gitosis is documented here.

Git Clients

Eclipse has a very good plugin for Git.
For OSX I use SourceTree Git application.

Install Gitolite

Since the version 3 of gitolite (released in May 2012) it seems to be possible to install gitolite directly under the Web Server process. Therefore it is no more necessary to create additional users for git and gitolite. Git and Gitolite are installed in regular folders. The user under which gitolite executes is the same as the web server process. The instructions are based on the location of gitolite in the variable GITOLITE_HTTP_HOME 


Configure OSX to add gitolite to the path variable. You must create a file gitolite in /etc/paths.d add path to /etc/paths.d and add


Create gitolite location

sudo mkdir $GITOLITE_HTTP_HOME/bin

Download gitolite and install it

cd /Users/Shared/Projects
git clone git:// 
sudo gitolite/install -ln $GITOLITE_HTTP_HOME
sudo HOME=$GITOLITE_HTTP_HOME gitolite setup -a admin

# move gitolite git repositories onto the desired location
sudo mkdir /Users/Shared/git/repositories
sudo mv $GITOLITE_HTTP_HOME/repositories/* /Users/Shared/git/repositories
sudo rm -R $GITOLITE_HTTP_HOME/repositories
sudo ln -s /Users/Shared/git/repositories repositories

#add at the beginning of file .gitolite.rc located in $GITOLITE_HTTP_HOME
#modify the file
GIT_CONFIG_KEYS => 'gitweb\..* hooks\..*'

sudo chown -R www $GITOLITE_HTTP_HOME

Configure gitolite to support http access. See instructions for new version 3.0 of gitolite.

sudo mkdir /Library/WebServer/Documents/bin
sudo ln -s /Users/Shared/Projects/gitolite gitolite-source
sudo chown -R www /Library/WebServer/Documents/bin
sudo chown -R www /Users/git

Create configuration file gitolite.conf in /etc/apache2/others

SetEnv GIT_PROJECT_ROOT /usr/local/gitolite/repositories
ScriptAlias /git/ /Library/WebServer/Documents/bin/gitolite-source/src/gitolite-shell/
ScriptAlias /gitmob/ /Library/WebServer/Documents/bin/gitolite-source/src/gitolite-shell/
SetEnv GITOLITE_HTTP_HOME /usr/local/gitolite

<Location /git>
    AuthType Basic
    AuthName "Git Access"
    Require valid-user
    AuthUserFile /Users/Shared/git/svn-users

Install GitWeb

Create configuration file for Gitweb in /etc/gitweb.conf
$projectroot = '/Users/Shared/git';
$site_name   = 'Rommie git repositories';

Create configuration file for Apache server in /etc/apache2/others/gitweb.conf

Alias /gitweb /usr/local/git/share/gitweb
<Directory /usr/local/git/share/gitweb>
    Options ExecCGI +FollowSymLinks 
    AllowOverride All
    order allow,deny
    Allow from all
    AddHandler cgi-script .cgi 
    DirectoryIndex gitweb.cgi 
    AuthType Basic 
    AuthName "Gitweb Access" 
    Require valid-user 
    AuthUserFile /Users/Shared/git/svn-users


Configure Apache

The Apache server location for the files to be served is defined with the ''DocumentRoot'' attribute in the main configuration file. Configure the web server to support HTTP and HTTPS protocols.

You should configure the access rights with a directory block to limit access to sensitive files.

Apache Configuration

Navigate to /etc/apache2/other and use your favorite command line text editor as root to make a file named anything you want:

        cd /etc/apache2/other
        sudo nano svn.conf

Now that you are editing this file as root, you want to make it contain the following bits, and save:

        LoadModule dav_svn_module libexec/apache2/
        LoadModule authz_svn_module libexec/apache2/

        <Location /svn>
          DAV svn
          SVNParentPath /Users/Shared/svn
          AuthType Basic
          AuthName "SVN"
          AuthUserFile /Users/Shared/svn/svn-users
          AuthzSVNAccessFile /Users/Shared/svn/svn-accesses
          Require valid-user

Note that you can leave off all the authentication related stuff if you didn't want authentication on your repository. Also note that you need to fix the SVNParentPath and the AuthUserFile if you varied from my directions.

Activate SSL

Create a new test certificate for internal use. Do not forget to step the number of days the certificate is active. See also instructions here.

        openssl req -new -x509 -days 1000 -nodes -out server.crt -keyout server.key

  • Copy the server.crt and server.key files into ''/private/etc/apache2/'' directory
  • Edit ''/etc/apache2/http.conf'' uncommented include ''extra/httpd-ssl.conf''
  • Reboot the Apache server with sudo apachectl restart

Restart Apache

Now restart Apache. This can be done in the Sharing panel of the System Preferences application. Just click to turn off, and then back on, Web Sharing.

Now, if you didn't make a mistake, you should be ready! Try going to http://localhost/svn/reposname (where you need to put the repository name you chose earlier instead of ''reposname''!) and see what happens.

If you are lucky you'll see revision 0 of your repository. But most people are human and will have made a typo that results in an error. For hints on what created the error, trying checking out /var/log/system.log and /var/log/apache2/error_log for hints as to what you did wrong. (And as a bonus, the Console application works great for monitoring the logs as they are written to!)

Configure Subversion

Mac OS X 10.9 Mavericks ships with an older Subversion installed. It also ships with Apache 2.2 installed. It does not, however, ship with a pre-installed subversion repository configuration or Subversion through Apache. To install Subversion use the WanDisco package and copy the new programs. You also need to copy the new Apache modules in the OS location.

        $ sudo cp /opt/subversion/bin/svn* /usr/bin
        or add /usr/local/bin to the path
        $ sudo cp /opt/subversion/lib/svn-apache/*.so /usr/libexec/apache2 ##you should stop before the server and restart it after the copy operation

So let's say you want to create your own subversion repository host on your Leopard box your own source code management goodness?

You could go to the subversion homepage and download the free Subversion book and sort through the instructions trying to figure out how they apply to you... Or you could follow these simple directions which I've laid out for you.

Make a Repository

The first thing you need to do is to make a repository. Actually, for my needs, I had to make multiple repositories, so these instructions will set everything up to make that work. It really only changes two steps anyway, so it isn't a big deal.

Now I decided to make my repository collection root directory be in /Users/Shared/, but you can really make it be anything you want, including the ever popular /usr/local. Just be sure to replace /Users/Shared/ with your directory of choice whenever necessary.

Anyway, I opened Terminal and entered the following commands:

        $ sudo mkdir /Users/Shared/svn
        $ sudo mkdir /Users/Shared/svn/reposname
        $ sudo svnadmin create /Users/Shared/svn/repository-name
        $ sudo chown -R www:www reposname

or update existing repositories to the new subversion version with:

        $ sudo svnadmin upgrade /Users/Shared/svn/repository-name

Note that you can create multiple repositories by following these directions but replacing every instance of "repository-name" with the name of the repository you want to use. Thus, if you have multiple repositories, you will have multiple directories in /Users/Shared/svn.

Make Access

Most directions do this later, but I'm going to do it now because I think you are smarter than that.

You might want to create a password file, unless you want full public access to your repository. For our purposes, simple http basic authentication is fine, but remember that the password is only weakly encoded and the traffic isn't encoded at all, so a snooper could get to the information if you access your computer outside of your own computer.

So if you do want to use authentication, create the password using the following command, substituting username for a user name of your choice, and following the directions for password creation:

        $ sudo htpasswd -cm /etc/apache2/svn-auth-file username

To add other users to the file, just ditch the c switch in the -cm options to htpasswd. The c switch stood for create, and since the file has been created you don't want it anymore.

Note that you can put the svn-auth-file anywhere you want, but this seemed like a good place for it in my mind. (Just remember where you hid it from yourself if you put it anywhere else).

Where From Here?

And now you are ready to use your repository. At this point I figure you already know how to use SVN and don't need my help anymore. But if you need to know how to use SVN, just refer to their book "Version Control with Subversion", which tells you everything you need to know, including how to make your server better!

Install webSVN

WebSVN package is a set of PHP scripts allowing to browse and explore a SVN repository through a web browser interface.
  • * Download the latest release of WebSVN home page
  • * Activate PHP module in Apache 2 server
         sudo nano /etc/apache2/httpd.conf
     uncomment the line # LoadModule php5_module libexec/apache2/

  • Install WebSVN under /Library/WebServer/Documents
  • Read the install.txt and update the configuration of the package. My repositories are stored under /Users/Shared/svn.

You may wish to provide an authentication mechanism for WebSVN. One obvious solution is to protect the entire WebSVN directory with some form of Apache authentication mechanism, but that doesn't allow for per repository authentication. WebSVN provides and access rights mechanism that uses your SVN access file to control read access to the repository. This means that you only have to maintain one file to define both Subversion and WebSVN access rights.

For this to work, you need to configure your authentication method to the /websvn/ directory. This should be the same authentication method as you use for the svn repositories themselves. Here's an example - the file is named websvn.conf and is located in /etc/apache2/other:

<Location /websvn>
   AuthType Basic
   AuthName "SVN"
   AuthUserFile /Users/Shared/svn/svn-users
   Require valid-user

cd /Library/WebServer/Documents/websvn/include
     sudo cp distconfig.php config.php
     sudo nano config.php

     add information in the file and activate


If necessary add read access to the root directory containing all repositories with the lines at the beginning of the Subversion access control file 

* = r

Install iF.SVNAdmin

The tool iF.SVNAdmin package is a set of PHP scripts allowing to manage SVN repositories. The tool is quite useful if you have quite a lot of users and projects. The management of repositories, users, groups, and access paths is quite comfortable.


  • I decided to drop Gitolite - I had huge problems to install the version 3 and missed more and more the not supported gitweb or similar tool -. I selected gitlib and I am very satisfied with this tool. Cudos to the developer James Moger, see also discussions in Google groups.
  • I moved to the newest version of Subversion and Git regularly through 2012 and 2013 without any troubles.
  • I installed OSX Mavericks in November2013 and discovered once again that quite a few things changed.
    • You must reinstall Subversion binaries. See the above instructions.
    • You must again reinstall the Subversion apache module. The installation of OSX Mavericks erases the previously installed modules and the server does not start anymore
    • You must reinstall properly Git. See the above instructions.
  • I installed OSX Mountain Lion in July 2012 and discovered once again that quite a few things changed.
    • The apache server is no more supported through a user interface. Therefore use the following command line instructions sudo apachectl start | stop | restart | configtest
    • I must reinstall the subversion apache modules. The installation of OSX Mountain Lion erases the previously installed modules. Now the 1.7.x distribution of subversion is installed.