天天看点

repo拉取代码命令使用学习

关于repo

Android使用Git作为代码管理工具,开发了 Gerrit 进行代码审核以便更好的对代码进行集中式管理,还开发了 Repo 命令行工具,对 Git 部分命令封装,将百多个 Git 库有效的进行组织。

下载安装repo

curl http://git-repo.googlecode.com/files/repo-1.12 > ~/bin/repo      

然后将repo加入系统变量

如果是在mac下安装了brew,可以用如下命令行安装repo:

brew install repo      

repo常用指令

repo init (下载repo并克隆manifest)

repo init –u URL [OPTIONS]      

-u:指定一个URL,其连接到一个maniest仓库

-m:在manifest仓库中选择一个xml文件

-b:选择一个maniest仓库中的一个特殊的分支

命令repo init 要完成如下操作:

完成repo工具的完整下载,执行的repo脚本只是引导程序

克隆清单库manifest.git (地址来自于-u 参数)

克隆的清单库位于manifest.git中,克隆到本地.repo/manifests.清单.repo/manifest.xml只是符号链接,它指向.repo/manifests/default.xml

如果manifests中有多个xml文件,repo init 可以任意选择其中一个,默认选择是default.xml

repo init -u git://sobird.me/manifest.git      

repo sync(下载代码)

用于参照清单文件.repo/manifest.xml克隆并同步版本库。如果某个项目版本库尚不存在,则执行repo sync 命令相当于执行git clone,如果项目版本库已经存在,则相当于执行下面的两条指令:

git remote update

相当于对每一个remote源执行了fetch操作

git rebase origin/branch

针对当前分支的跟踪分支执行rebase操作。

repo sync      

也可以选择克隆其中的一个项目:

repo sync platform/build      

关于更多repo命令的使用方法,可参考下面地址:

-《Repo 详解》

声明: 本文采用 BY-NC-SA 协议进行授权,转载请注明转自 Sobird:https://sobird.me/repo-cli-get-started.htm

继续阅读