[移一棵树容易,挪一片森林难啊!]
一、安装git dameon$ sudo apt-get install git-daemon-run
二、设置仓库目录
修改/etc/sv/git-daemon/run,配置git tree的目录以及共享目录
$ vi /etc/sv/git-daemon/run
#!/bin/sh
exec 2>&1
echo 'git-daemon starting.'
exec chpst -ugitdaemon \
/usr/lib/git-core/git-daemon --export-all --base-path=/pub/gittrees /pub/gittrees
? --export-all:导出(共享)所有目录,否则要在每个要导出的目录下作如下操作:
$ touch git-daemon-export-ok
? --base-path: 映射仓库地址。/pub/gittrees是镜像目录。比如:
git://your_server_ip/repository/platform/manifest.git,则仓库地址在
/pub/gittrees/repository/platform/manifest.git
三、制作android服务器镜像
$ mkdir /pub/gittrees/android-mirror/
$ chown git.git /pub/gittrees/android-mirror/
$ cd /pub/gittrees/android-mirror/
$ repo init -u git://android.git.kernel.org/platform/manifest.git --mirror
$ repo sync -j18
这会花很长时间,为将来使用方便,需要耐心等待。
四、建立自己软件团队的公用版本库 1. 建立版本库
$ mkdir /pub/gittrees/our-repository
$ cd /pub/gittrees/our-repository
$ repo init -u /pub/gittrees/android-mirror/platform/manifest.git �Cmirror
$ repo sync
1.1 修改 platform/manifest.git/config 文件,追加如下几行,允许上传补丁
[daemon]
uploadpack=true
uploadarch=true
receivepack=true
1.2 检出/修改/提交 platform/manifest.git
$ cd /tmp
$ git clone git://your-server-ip/our-repository/platform/manifest.git
$ cd manifest; vi default.xml
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="korg"
- fetch="git://android.git.kernel.org/"
+ fetch="git://your-server-ip/our-repository/"
review="review.source.android.com" />
<default revision="master"
remote="korg" />
...
2. 创建团队的master-2.1_r2开发分支( 在另一台电脑上)$ git commit -am ‘modified to fetch from local host’
$ git push git://your-server-ip/our-repository/platform/manifest.git
[注] git push 过程可能会出现error, 可查看日志/var/log/git-daemon/current, 可能需要手动修改platform/manifest.git/目录下objects和refs的权限
$ cd /pub/gittrees/our-repository/platform/manifest.git
$ sudo chmod 777 -R objects refs
2.1 下载android-2.1_r2代码
$ mkdir ~/my-android-code ~/bin/repo
$ cd ~/my-android-code
$ curl http://android.git.kernel.org/repo > ~/bin/repo
$ chmod a+x ~/bin/repo
$ vi ~/bin/repo
#!/bin/sh
## repo default configuration
##
# REPO_URL='git://android.git.kernel.org/tools/repo.git'
REPO_URL='git://your-server-ip/our-repository/repo.git'
REPO_REV='stable'$ repo init -u git://your-server-ip/our-repository/platform/manifest.git -b android-2.1_r2
按提示输入自己的用户名和邮箱即可
$ repo sync -j5
等10分钟左右,代码下载完成。(-j5表示同时下5个项目,可快点!)
2.2 建立主干开发分支
$ repo start master-2.1_r2 --all
2.3 设置远程仓库的别名为my-korg
$repo forall -c 'git remote add mykorg /pub/gittrees/our-repository/\
$REPO_PROJECT.git $@'
注:删除myorg:
$ repo forall -c git remote rm myorg
2.4 将分支提交至公共版本仓库
$ repo forall -c git push myorg master-2.1_r2:refs/heads/master-2.1_r2
$ repo sync
2.5 为你的公共版本库建立manifest分支
$ cd ~/my-android-code/.repo/manifests
$ git checkout -b master-2.1_r2
$ vi default.xml
按如下方式修改
<manifest>
<remote name="korg"
- fetch="git://android.git.kernel.org/"
+ fetch="git://172.20.158.5/our-repository/" review="review.source.android.com" />
- <default revision="refs/tags/android-2.1_r2"
+ <default revision="refs/heads/master-2.1_r2"
remote="korg" />
修改完成后提交并将branch提交至公共版本库
$git commit -a
$git remote add our-repository /pub/gittrees/your-repository/platform/manifest.git
$git push your-repository master-2.1_r2:refs/heads/master-2.1_r2
现在我们自己团队的公共版本库创建完成。
公共版本库的路径为:
/pub/gittrees/our-repository/
外部可访问仓库地址为:
git://your-server-ip/your-repository/platform/manifest.git
Repo访问方法:
$repo init -u git://your-server-ip/our-repository/platform/manifest.git �Cb master-2.1_r2
[附]
http://blog.csdn.net/tjd0227/archive/2010/06/01/5640418.aspx
http://blog.csdn.net/tjd0227/archive/2010/06/01/5640480.aspx
http://blogold.chinaunix.net/u1/40978/showart_2271288.html
http://blogold.chinaunix.net/u3/92787/showart_2060961.html
http://www.omappedia.org/wiki/Android_Miscellaneous
https://gforge.ti.com/gf/project/omapandroid/wiki/?pagename=OMAP-Android+Mirror
http://www.javaeye.com/topic/832391
http://www.javaeye.com/topic/690683