2012年3月6日 星期二

建立 git server

【轉貼】ox0spy's blog

環境:debian 6.04
1. install
# run on server
$ sudo apt-get install git-core gitosis
(用 apt 安裝 gitosis,會自動幫你產生一個user:gitosis)

2. generate ssh key
# run on your pc
$ ssh-keygen -t dsa  (可以製造其它演算法的security_key)

3. upload the ssh public key (kerdir)
# run on your pc
$ scp ~/.ssh/id_dsa.pub USER@YOUR_SERVER:/tmp

4. create admin repository
# run on server
$ sudo -H -u gitosis gitosis-init < /tmp/id_dsa.pub # monkey's ssh public key
$ sudo chmod 755 /srv/gitosis/repositories/gitosis-admin.git/hooks/post-update

5. checkout gitosis-admin
# run on your pc
$ git clone gitosis@YOUR_SERVER:gitosis-admin.git

6. grante right for members  (gitosis.conf)
# run on your pc, add new group - android
[group android] # team name
writable = 0xdroid-0x5 0xdroid-0x4 # project name
members = monkey@debian cow@ubuntu # members

# add cow's ssh public key
$ git add keydir/cow@ubuntu.pub gitosis.conf

# grante cow commit right to android
$ git commit -m "Granted cow commit right to android"
$ git push # now, cow has the commit right.

7. create new repositories
There are two ways to commit your code:
a. checkin your codes from zero
# create new repositories - 0xdroid-0x5.git
$ cd YOUR-CODE-DIR
$ mkdir 0xdroid-0x5.git && cd 0xdroid-0x5.git
$ git init

# modify .gitignore

$ git remote add origin gitosis@YOUR_SERVER:0xdroid-0x5.git
$ git add .
$ git commit -m "initial import"
$ git push origin master:refs/heads/master

b. checkin your codes from old git repo
$ cd YOUR-OlD-GiT-REPO
$ git remote -v
$ git pull # update
$ git remote rm origin
$ git remote add origin gitosis@YOUR_SERVER:0xdroid-0x5.git
$ git push origin master:refs/heads/master

8. checkout codes
$ git clone gitosis@YOUR_SERVER:0xdroid-0x5.git

ref:  ox0spy's blog

gitosis.conf 內容:
[group system-TL10RAx]
writable = TL10RAx-intel
members = name@xxxx-59MB40IA name2@TTT-ThinkPad-X220
members後面不要加副檔.pub

沒有留言:

張貼留言