Chinaunix首页 | 论坛 | 博客
  • 博客访问: 161236
  • 博文数量: 14
  • 博客积分: 255
  • 博客等级: 二等列兵
  • 技术积分: 621
  • 用 户 组: 普通用户
  • 注册时间: 2010-11-27 13:12
个人简介

热爱推理

文章分类
文章存档

2015年(2)

2014年(1)

2013年(5)

2011年(1)

2010年(5)

我的朋友

分类: Android平台

2015-11-29 15:37:35

这篇文章主要作为一个学习笔记,同时也希望可以帮助到其他有需要的朋友

首先感谢如下几篇文章的指导:

http://blog.csdn.net/hansel/article/details/9798189
http://blog.csdn.net/lb5761311/article/details/47723455

http://blog.csdn.net/sunweizhong1024/article/details/8055372
http://blog.csdn.net/itleaks/article/details/30021395?utm_source=tuicool&utm_medium=referral


正文 -- repo完整安装及项目同步


1. 下载repo bootstrap(repo的启动文件,用于安装完整的repo)

  1. git clone git://git.omapzoom.org/git-repo.git
clone完成后,repo bootstrap文件位于如下路径:

  1. ./git-repo/repo


2. 安装repo bootstrap

a. 创建本地repo

  1. mkdir ~/bin/
  2. cp ./git-repo/repo ~/bin/

b. 设置环境变量:

  1. vi ~/.profile
确保有如下三行

  1. if [ -d "$HOME/bin" ] ; then
  2. PATH="$HOME/bin:$PATH"
  3. fi

c. 使环境变量生效

  1. source ~/.profile
使bin路径生效,以后可以直接命令行repo执行


3. patch repo bootstrap

  1. vi ~/bin/repo
按照如下diff做修改

  1. -- REPO_URL = ''
  2. ++ REPO_URL = 'git://codeaurora.org/tools/repo.git'
这一步骤必须做,否则会在第4步时,出现如下log中repo URL下载超时的问题:

  1. fatal: Cannot get /clone.bundle
  2. fatal: error [Errno 101] Network is unreachable
超时是因为gerrit.googlesource.com被墙了


4. 创建项目manifest清单,repo会以manifest中的配置来同步项目

a. 在server上创建manifest.git空仓库,在此以如下remote url地址为例:

  1. cd manifest.git
  2. git remote -v
  3. origin git:manifest (fetch)
  4. origin git:manifest (push)

b. 在客户端上clone manifest仓库

  1. git clone git:manifest

c. 创建default.xml文件,repo默认会以manifest仓库的default.xml为配置文件

  1. cd manifest
  2. vi default.xml
 输入如下内容:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <manifest>
  3.     <remote name="origin"
  4.              fetch="git:"
  5.              review="" />
  6.     <default revision="master"
  7.              remote="origin"
  8.              sync-j="4" />


  9.     <project path="test" name="test"/>
  10. </manifest>

manifest配置分为三大部分:remote default 以及 project,分别进行讲解

remote:
指代同步项目的一个server地址(可有多个remote)
name为一个唯一标识的名字
fetch为url的前缀,在我们的例子当中,仓库路径一概都是git:XXX,所以前缀就是"git:"
review暂时可以不予考虑,以例子中的为准

default:
指代同步项目使用的默认server配置:
revision指代git分支的名字
remote指代使用的remote server
sync-j表示同步项目时并行个数

project:
指代同步项目的git仓库,这里假设我们有一个git:test的仓库(可以有多个)
name就是git仓库名test
path就是设置仓库存放在repo project的哪个目录下,这里就直接设置为存放在repo project子目录的test中

d. 同步default.xml的修改至服务器

  1. git add default.xml
  2. git commit -m "udpate default.xml for repo sync test"
  3. git push origin master


5. 安装完整版repo

a. 先创建并进入一个自定义目录:

  1. mkdir test-project
  2. cd test-project

b. 执行如下repo命令,用于初始化repo,并且指定了mainfest项目清单

  1. repo init -u git:manifest

c. 执行完后,先会有如下log,这里才是真正的clone了完整版的repo:

  1. Get git://codeaurora.org/tools/repo.git
  2. remote: Counting objects: 3425, done.
  3. remote: Total 3425 (delta 0), reused 0 (delta 0)
  4. Receiving objects: 100% (3425/3425), 753.71 KiB, done.
  5. Resolving deltas: 100% (2311/2311), done.
  6. From git://codeaurora.org/tools/repo
  7. * [new branch] aosp-new/maint -> origin/aosp-new/maint
  8. * [new branch] aosp-new/master -> origin/aosp-new/master
  9. * [new branch] aosp-new/stable -> origin/aosp-new/stable
  10. * [new branch] caf-stable -> origin/caf-stable
  11. * [new branch] master -> origin/master
  12. * [new branch] stable -> origin/stable
  13. * [new tag] v1.0 -> v1.0
  14. * [new tag] v1.0.1 -> v1.0.1
  15. ......
  16. Getting manifest ...
  17. from git:manifest
  18. remote: Counting objects: 18, done.
  19. remote: Compressing objects: 100% (16/16), done.
  20. remote: Total 18 (delta 4), reused 0 (delta 0)
  21. Unpacking objects: 100% (18/18), done.
  22. From git:manifest
  23. * [new branch] master -> origin/master

d. 接下来会要求初始化repo帐号信息,例子中与git保持一致,例如如下,中括号中的是git帐号信息,
在冒号后输入与其一致的信息即可:

  1. Your Name [willqian]: willqian
  2. Your Email [690004467@qq.com]: 690004467@qq.com
  3. Your identity is: willqian <690004467@qq.com>
  4. is this correct [y/n]? y

e. 此时,目录下会有一个隐藏文件夹.repo,完整版的repo位于路径

  1. .repo/repo/


6. repo同步项目

a. 同步

  1. cd test-project
  2. repo sync
完成后,可以通过log看到,manifest项目清单中列出的test仓库已clone完毕
我们进入到test仓库中查看,发现有一个问题,此时处于no branch的状态

  1. cd test
  2. git status
  3. # Not currently on any branch.
  4. nothing to commit (working directory clean)

b. 切到master分支上

  1. cd test-project
  2. repo start master --all
通过这个操作,我们再次进入到test仓库中,看到已处于master分支上

  1. cd test
  2. git status
  3. # On branch master
  4. nothing to commit (working directory clean)


至此,repo的完整安装以及项目同步的例子便以完成

阅读(7291) | 评论(0) | 转发(1) |
给主人留下些什么吧!~~