ubuntu12.04下建立gitolite服务

4 篇文章 0 订阅

http://computercamp.cdwilson.us/git-gitolite-git-daemon-gitweb-setup-on-ubunt

http://www.ossxp.com/doc/git/gitolite.html

 

http://blog.airmio.com/2012/05/install-git-server-on-ubuntu-12/

 

 

git setup

Install git and doc:

sudo apt-get install git-core git-doc

Setup your username and email:

git config --global user.name "Your Name"
git config --global user.email your@email.com

gitolite setup

gitolite uses ssh keys to manage access to the git repositories. In the following steps, we set up gitolite to initialize its admin repository with your public key.

Copy over your pubkey from your local machine to the git server:

# FROM YOUR LOCAL MACHINE
scp ~/.ssh/id_rsa.pub git.server:/tmp/your-username-goes-here.pub

Create gitolite group and gitolite user:

sudo addgroup gitolite
sudo adduser --disabled-password --home /home/gitolite --ingroup gitolite gitolite

Install gitolite:

sudo apt-get -y install gitolite

Append www-data to gitolite group so gitweb can access the repos:

sudo usermod -a -G gitolite www-data

and make sure that groups are updated for apache:

sudo service apache2 restart

Run the gitolite setup:

sudo su - gitolite
gl-setup /tmp/your-username-goes-here.pub

Setup will allow you to modify gitolite config umask settings so that new repos are given permissions to enable gitweb and git-daemon export:

# change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---'

If for some reason you weren’t able to edit .gitolite.rc during the gl-setup phase, edit .gitolite.rcand fix permissions so that gitolite group has read access to repositories:

emacs /home/gitolite/.gitolite.rc
# change $REPO_UMASK = 0077; to $REPO_UMASK = 0027; # gets you 'rwxr-x---'
chmod g+r /home/gitolite/projects.list
chmod -R g+rx /home/gitolite/repositories

Exit out of gitolite user session and return to your normal user account:

exit

You should now be able to clone the gitolite-admin.git repository that’s created automatically by the gitolite setup script:

# FROM YOUR LOCAL MACHINE
git clone gitolite@git.server:gitolite-admin.git

Edit gitolite.conf to enable gitweb and git-daemon export for testing:

# FROM YOUR LOCAL MACHINE
cd gitolite-admin
emacs conf/gitolite.conf
# change to:
repo    testing
      RW+     =   @all
      R       =   daemon
testing "Owner" = "Test repo"
git add conf/gitolite.conf
git commit -m "Enabled gitweb and git-daemon export for testing repo"
git push
cd ..

Setting the repo owner and description automatically gives read access to gitweb so you don’t have to specify it explicitly.

Clone testing and add a file (so it’s not empty):

git clone gitolite@git.server:testing.git
cd testing
echo "README" > README
git add README
git commit -m "Added README"
git push origin master

gitweb setup

Install gitweb:

sudo apt-get install highlight gitweb

Change the gitweb configuration to use the gitolite repo paths:

sudo emacs /etc/gitweb.conf
# change $projectroot to /home/gitolite/repositories
# change $projects_list to /home/gitolite/projects.list

Now you should be able to see the testing repository in gitweb at:

http://git.server/gitweb/

git-daemon setup

sudo apt-get install git-daemon-run

Now we need to change the sv config for git-daemon so that it runs as the gitdaemon user and gitolite group (since gitolite group has read access to the repositories)

sudo emacs /etc/sv/git-daemon/run

Change:

#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon \
  "$(git --exec-path)"/git-daemon --verbose --base-path=/var/cache /var/cache/git

to:

IMPORTANT: notice the change from -ugitdaemon to -ugitdaemon:gitolite

#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon:gitolite \
  "$(git --exec-path)"/git-daemon --verbose --base-path=/home/gitolite/repositories /home/gitolite/repositories

Restart git-daemon:

sudo sv restart git-daemon

You should now be able to clone the testing repo via the git protocol:

git clone git://git.server/testing.git
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值