android repo/git server 建立过程

转自http://blog.csdn.net/tjd0227/article/details/5640418

1、 安装git dameon

[c-sharp] view plain copy print ?
  1. $ 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 ?
  1. $ vi etc/sv/git-daemon/run   
  2.  
  3. #!/bin/sh   
  4. exec 2>&1  
  5. echo 'git-daemon starting.'  
  6. exec chpst -ugitdaemon /  
  7.   /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&gt;&amp;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 ?
  1. $ 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 ?
  1. $ mkdir  /pub/gittrees/android-mirror/  
  2. $ chown git.git  /pub/gittrees/android-mirror/       
  3. $ cd  /pub/gittrees/android-mirror/  
  4. $ repo init -u git://android.git.kernel.org/platform/manifest.git --mirror   
  5. $ 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 ?
  1. $ mkdir  /pub/gittrees/our-repository  
  2. $ cd  /pub/gittrees/our-repository  
  3.   
  4. $ 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 ?
  1. -           fetch="git://android.git.kernel.org/"  
  2. +           fetch="git://your-server-ip/android-mirror/"  
  3.   
  4. $ repo sync  
<textarea rows="5" cols="81" name="code">- fetch=&quot;git://android.git.kernel.org/&quot;+ fetch=&quot;git://your-server-ip/android-mirror/&quot;$ repo sync</textarea>

 

 

2、创建团队的master-2.1_r2开发分支

1、下载android-2.1_r2代码

[c-sharp] view plain copy print ?
  1. $ mkdir my-android-code  
  2. $ cd my-android-code  
  3. $ 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 ?
  1. -           fetch="git://android.git.kernel.org/"  
  2. +           fetch="git://your-server-ip/our-repository/"   
  3.   
  4. $ repo sync  
<textarea rows="5" cols="70" name="code">- fetch=&quot;git://android.git.kernel.org/&quot;+ fetch=&quot;git://your-server-ip/our-repository/&quot; $ repo sync</textarea>

 

10分钟左右,代码下载完成。

 

2、下载完成后建立主干开发分支

[c-sharp] view plain copy print ?
  1. $ 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 ?
  1. $repo forall -c 'git remote add mykorg /pub/gittrees/our-repository//    
  2.            $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 ?
  1. $ repo forall -c git push myorg master-2.1_r2:refs/heads/master-2.1_r2  
  2. $ 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 ?
  1. $ cd my-android-code/.repo/manifests  
  2. $ git checkout -b master-2.1_r2  
  3. $ 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 ?
  1. <manifest>  
  2.    <remote  name="korg"  
  3. -           fetch="git://android.git.kernel.org/"  
  4. +           fetch="git://172.20.158.5/our-repository/"            review="review.source.android.com" />  
  5. -  <default revision="refs/tags/android-2.1_r2"  
  6. +  <default revision="refs/heads/master-2.1_r2"  
  7.             remote="korg" />  
<textarea rows="9" cols="71" name="code">&lt;manifest&gt; &lt;remote name=&quot;korg&quot;- fetch=&quot;git://android.git.kernel.org/&quot;+ fetch=&quot;git://172.20.158.5/our-repository/&quot; review=&quot;review.source.android.com&quot; /&gt;- &lt;default revision=&quot;refs/tags/android-2.1_r2&quot;+ &lt;default revision=&quot;refs/heads/master-2.1_r2&quot; remote=&quot;korg&quot; /&gt;</textarea>

 

修改完成后提交将branch提交至公共版本库

[c-sharp] view plain copy print ?
  1. $git commit -a  
  2. $git remote add our-repository /pub/gittrees/your-repository/platform/manifest.git  
  3. $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 ?
  1. $repo init -u git://your-server-ip/our-repository/platform/manifest.git –b master-2.1_r2  

 

你可能感兴趣的:(android,server,git,tree,服务器,branch)