转自http://blog.csdn.net/tjd0227/article/details/5640418
1、
安装git dameon
[c-sharp] view plain copy print ?
- $ sudo apt-get install git-daemon-run
<textarea rows="1" cols="50" name="code">$ sudo apt-get install git-daemon-run</textarea>
2、设置仓库目录
修改/etc/sv/git-daemon/run,配置git tree的目录以及共享目录
[c-sharp] view plain copy print ?
- $ 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
<textarea rows="8" cols="50" name="code">$ vi etc/sv/git-daemon/run #!/bin/shexec 2>&1echo 'git-daemon starting.'exec chpst -ugitdaemon / /usr/lib/git-core/git-daemon --export-all --base-path=/pub/gittrees /pub/gittrees</textarea>
? --export-all:导出(共享)所有目录,否则要在每个要导出的目录下作如下操作:
[c-sharp] view plain copy print ?
- $ touch git-daemon-export-ok
<textarea rows="1" cols="50" name="code">$ touch git-daemon-export-ok</textarea>
? --base-path: 映射仓库地址。/pub/gittrees是镜像目录。比如:
git://your_server_ip/ repository/platform/manifest.git,则仓库地址在
/pub/gittrees/ repository/platform/manifest.git
3、制作android服务器镜像
[c-sharp] view plain copy print ?
- $ 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
<textarea rows="5" cols="82" name="code">$ 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</textarea>
这会花很长时间,为将来使用方便,需要耐心等待。
4、建立自己软件团队的公用版本库
1、建立版本库
[c-sharp] view plain copy print ?
- $ mkdir /pub/gittrees/our-repository
- $ cd /pub/gittrees/our-repository
-
- $ repo init -u git://your-server-ip/android-mirror/platform/manifest.git --mirror
<textarea rows="6" cols="81" name="code">$ mkdir /pub/gittrees/our-repository$ cd /pub/gittrees/our-repository$ repo init -u git://your-server-ip/android-mirror/platform/manifest.git --mirror</textarea>
修改.repo/manifest.xml
[c-sharp] view plain copy print ?
- - fetch="git://android.git.kernel.org/"
- + fetch="git://your-server-ip/android-mirror/"
-
- $ repo sync
<textarea rows="5" cols="81" name="code">- fetch="git://android.git.kernel.org/"+ fetch="git://your-server-ip/android-mirror/"$ repo sync</textarea>
2、创建团队的master-2.1_r2开发分支
1、下载android-2.1_r2代码
[c-sharp] view plain copy print ?
- $ mkdir my-android-code
- $ cd my-android-code
- $ repo init -u git://your-server-ip/our-repository/platform/manifest.git –b android-2.1_r2
<textarea rows="6" cols="88" name="code">$ mkdir my-android-code$ cd my-android-code$ repo init -u git://your-server-ip/our-repository/platform/manifest.git –b android-2.1_r2</textarea>
按提示输入自己的用户名和邮箱即可
修改.repo/manifest.xml
[c-sharp] view plain copy print ?
- - fetch="git://android.git.kernel.org/"
- + fetch="git://your-server-ip/our-repository/"
-
- $ repo sync
<textarea rows="5" cols="70" name="code">- fetch="git://android.git.kernel.org/"+ fetch="git://your-server-ip/our-repository/" $ repo sync</textarea>
等10分钟左右,代码下载完成。
2、下载完成后建立主干开发分支
[c-sharp] view plain copy print ?
- $ repo start master-2.1_r2 --all
<textarea rows="1" cols="50" name="code">$ repo start master-2.1_r2 --all</textarea>
3、设置远程仓库的别名为my-korg
[c-sharp] view plain copy print ?
- $repo forall -c 'git remote add mykorg /pub/gittrees/our-repository//
- $REPO_PROJECT.git $@'
<textarea rows="3" cols="82" name="code">$repo forall -c 'git remote add mykorg /pub/gittrees/our-repository// $REPO_PROJECT.git $@'</textarea>
注:删除myorg:
$ repo forall -c git remote rmmyorg
4、将分支提交至公共版本仓库
[c-sharp] view plain copy print ?
- $ repo forall -c git push myorg master-2.1_r2:refs/heads/master-2.1_r2
- $ repo sync
<textarea cols="77" name="code">$ repo forall -c git push myorg master-2.1_r2:refs/heads/master-2.1_r2$ repo sync</textarea>
5、
为你的公共版本库建立manifest分支
[c-sharp] view plain copy print ?
- $ cd my-android-code/.repo/manifests
- $ git checkout -b master-2.1_r2
- $ vi default.xml
<textarea rows="3" cols="50" name="code">$ cd my-android-code/.repo/manifests$ git checkout -b master-2.1_r2$ vi default.xml</textarea>
按如下方式修改
[c-sharp] view plain copy print ?
- <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" />
<textarea rows="9" cols="71" name="code"><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" /></textarea>
修改完成后提交并将branch提交至公共版本库
[c-sharp] view plain copy print ?
- $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
<textarea rows="3" cols="81" name="code">$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</textarea>
现在我们自己团队的公共版本库创建完成。
公共版本库的路径为:
/pub/gittrees/our-repository/
外部可访问仓库地址为:
git://your-server-ip/your-repository/platform/manifest.git
Repo访问方法:
[c-sharp] view plain copy print ?
- $repo init -u git://your-server-ip/our-repository/platform/manifest.git –b master-2.1_r2