Gerrit清单库配置(转载)

From:http://fatalove.iteye.com/blog/1340334

gerrit清单库是用来配合repo使用的。清单库中列出了gerrit服务器上的其他版本库。

客户端通过repo脚本下载清单库后,脚本会解析清单库中列出的库并自动下载。

首先执行repo init,下载版本库,然后执行repo sync下载所有库的代码。

 

首先将repo版本库克隆至本地并push到gerrit服务器。

git clone https://android.googlesource.com/tools/repo

 

创建一个空的清单库manifest.git,清单库中只有xml文件。

在清单库中创建default.xml文件,将manifest.git通过push传至gerrit服务器。

 

这是服务器就多了两个库:repo.git和manifest.git

default.xml内容:

<?xml version="1.0" encoding="UTF-8"?>  
<manifest>  
  <remote fetch="ssh://gerrituser@192.168.222.149:29418" name="remote_name1" review="192.168.222.1:8081"/>  
  
  <default remote="remote_name1" revision="master" />  
  
  <project name="test" path="android/packages" >  
    <copyfile dest="a_in_root.txt" src="a_in_test.txt"/>  
  </project>  
  
</manifest>

project标签的name属性值test为gerrit服务器中对应的的仓库名称;

project标签的path属性值表示客户端迁出代码是使用的根目录名称;

copyfile表示在代码下载下来之后将test仓库的src指定的文件复制到dest路径下。

 

default标签中的revision值为gerrit服务器上的分之名称或者commitid。

 

 

配置完成后,使用repo下载代码。

 

$ mkdir code
$ cd code
$ repo init -u ssh://admin@ip:29418/manifest.git -m default.xml --repo-url=ssh://user@ip:29418/tools/repo.git --repo-branch=master --no-repo-verify
$ repo sync
$ ls

通过ls可以查看到一个android/packages目录。

 

 

repo sync之后

[root@server44-137 ]# git branch 
* (no branch)

本地没有分支,可以执行git branch -r 查看有哪些远程分支,然后执行git checkout --track 远程分支名

[root@server44-137 ]# git branch -r
   remote-branch1
[root@server44-137 ]# git checkout --track remote-branch1
Branch remote-branch1set up to track remote branch remote-branch1from github.
Switched to a new branch 'remote-branch1'

 

posted @ 2014-03-03 16:57  泉水叮~咚  阅读(1013)  评论(0编辑  收藏  举报