Tuesday, April 26, 2011

Setup Remote Shared Git Repository on Linux

Recently I set up Git on a remote Linux machine so that a friend and I could collaborate on a few coding projects. Following are the steps I took to get it all set up. The Linux distro I have installed on the remote host is Ubuntu.


Step 1: Install Git. SSH into the remoteserver and install git using apt-get. This installs git under /usr/bin
sudo apt-get update
sudo apt-get install git-core

Step 2: Set up Git Users
sudo groupadd developers
sudo useradd -G developers -d /home/timmolter -m -s /bin/bash timmolter
sudo passwd timmolter

Step 3: Passwordless SSH

Logged into remote account:
mkdir .ssh
From local account**:
scp ~/.ssh/id_rsa.pub timmolter@hostname:.ssh/authorized_keys
**assuming you already have a SSH key. If not try here.

Step 4: Setup a shared repository
Using an account with sudo-rights ("manager" - not a developer user that you just created):
cd ~
mkdir -p repositories/project.git
cd repositories/project.git
git init --bare --shared=group
ls -l
sudo chgrp -R developers .
ls -l

Now you have your Git repository and you can push you project to it!

Step 5 (optional):

Setup a symbolic link to the repository so the user can access it directly from his/her account.
sudo ln -s /home/manager/repositories/project.git/ /home/timmolter/


Piece of cake!!!

References

kovshenin.com
useradd

No comments: