Git Server on Ubuntu

Taking care of your Linux box.
mejam
Havaldaar
Posts: 127
Joined: Sat Oct 18, 2008 12:30 pm
Location: Lahore
Contact:

Git Server on Ubuntu

Postby mejam » Mon Dec 15, 2008 4:51 pm

This is a simple how-to which describes an easy installation of GIT.

=============================================
#Installing GIT

apt-get install git-core git-svn gitweb

#Creating GIT user

sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--home /home/git \
git

#setting password
set ur desired password for git user by :

passwd git

#creating directory for repositories

sudo -u git mkdir /home/git/repositories

#to make repositories available, we need git-daemon

sudo -u git git-daemon --reuseaddr --verbose --base-path=/home/git/repositories/ --detach

#Git-daemon needs to be run at startup. For that there is a package named "git-daemon-run".One can install that package
as "apt-get install git-daemon-run" or can use this script. I recommend the script because it seems easy to me

sudo cat > /etc/init.d/git-daemon << EOF

#!/bin/sh

test -f /usr/bin/git-daemon || exit 0

. /lib/lsb/init-functions

GITDAEMON_OPTIONS="--reuseaddr --verbose --base-path=/home/git/repositories/ --detach"

case "$1" in
start) log_daemon_msg "Starting git-daemon"

start-stop-daemon --start -c git:git --quiet --background \
--exec /usr/bin/git-daemon -- ${GITDAEMON_OPTIONS}

log_end_msg $?
;;
stop) log_daemon_msg "Stopping git-daemon"

start-stop-daemon --stop --quiet --name git-daemon

log_end_msg $?
;;
*) log_action_msg "Usage: /etc/init.d/git-daemon {start|stop}"
exit 2
;;
esac
exit 0
EOF

#then run this command to system startup links

update-rc.d git-daemon defaults

#Now change working directory to repositories and create a new project

cd /home/git/repositories
mkdir project1
cd project1

# now create files that you want to in this project1 directory

git init

git add .

git commit -m "your Commit comments"

git remote add origion git@yourserver:repositories/project1.git

touch .git/git-daemon-export-ok

scp -rp .git git@yourserver.com:repositories/project1.git

Git server is now up...

#Now we can test our first clone from client..

git clone git@yourserver:repositories/project1
Regards
Abdulrehman

lambda
Major General
Posts: 3452
Joined: Tue May 27, 2003 7:04 pm
Location: Lahore
Contact:

Postby lambda » Mon Dec 15, 2008 6:44 pm

Watch out for the !
Isn't it amazing how so many people can type "linuxpakistan.net" into their browsers but not "google.com"?

mejam
Havaldaar
Posts: 127
Joined: Sat Oct 18, 2008 12:30 pm
Location: Lahore
Contact:

Postby mejam » Mon Dec 15, 2008 6:54 pm

Regards

Abdulrehman


Return to “Administration”

Who is online

Users browsing this forum: No registered users and 1 guest