OSX Server as Source Code Repository

11 Jun, 2014 07:06 AM
 OSX
  Git
OSX Server App brings lot of services to our hands and one feature that i am interested in is the easy to setup source code repo server simillar to bitbucket or github.

OSX Server app is available at App Store for 19.99 US$ (Download link). The Server App provides File Server, Web Server, Contacts Server etc. By installing Server app, any OSX installation can become OSX server. The earlier OSX server is now discountinued.
 
The repo server can be git or svn based and access can be configured through http/https and ssh. Here are a quick steps for setting a git repository server.

STEP 1 - Open Server App

Open server app and select Xcode on the left. Then select 'Repositories' tab and click on + as shown below to bring up the add repository dialog.

Server App


STEP 2 - Configure a Repo

In the first dropdown select "Host a Git Repository", give it a name and configure SSH and HTTP access permissions. SSH permissions are more granular. There are options for selecting individual users and groups and granting read and write permissions seperately. HTTP access on the other hand is provided as readonly to all and write access through http via login can be either turned on or off. A Screenshot is provided below - 

Hot Repo
Click on create and voila we have a hosted repo.

STEP 3 - Clone this repo and start using it

To know the exact url via http/https or ssh, double click on the newly created repo and get all the access urls for SSH, HTTP and HTTPS as shown below -

Server App Repo Details 

SSH and HTTPS access would require seperate configuration in the Server App under 'certificate' menu. Clone the repo using the commands shown below - 

$ git clone http://Sangha.local/git/HelloWorld.git
Cloning into 'HelloWorld'...
Username for 'http://Sangha.local': <Enter your OS login user name>
Password for 'http://<User Name>@Sangha.local': 
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

If you are using a self signed certificate then accessing the repository over https would require turning off ssl verification as shown below - 
git clone https://Sangha.local/git/HelloWorld.git -c http.sslVerify=false

Lets change something and commit and push back to repo.

$ cd HelloWorld
$ touch readme.txt
$ git add readme.txt 
$ git commit -m "Initial Commit"
[master (root-commit) c36e302] Initial Commit
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 readme.txt
$ git push origin master
Username for 'http://Sangha.local': <Enter your OS login user name>
Password for 'http://<User Name>@Sangha.local': 
Counting objects: 3, done.
Writing objects: 100% (3/3), 220 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Notifying OS X Server...
To http://Sangha.local/git/HelloWorld.git
 * [new branch]      master -> master


Done!