前言
为了理解repo的概念和熟悉掌握repo常见操作,本文基于github来给大家展示如何创建仓库,如何使用repo来管理多个仓库. 同时也能为大家展示如何在线管理自己的代码。
一、Repo是什么?
Repo是Google方便管理Android 多仓库开发的管理工具。 Repo 简化了跨多个代码库运行的流程,与 Git 相辅相成。 详情可以参考Google官方网站
二、Repo 安装(ubuntu)
1. 方式一
sudo apt-get update
sudo apt-get install repo
2.方式二
mkdir ~/bin
curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo
chmod a+x ~/bin/repo
3. 配置访问Git库的参数
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
三、创建manifest
1. 登录github网站
GitHub: Let’s build from here · GitHub, 创建manifest仓库.
2. 配置连接github的对应的key
3. 上传manifest.xml
同步代码
git clone git@github.com:account_name/manifest.git
manifest.xml(示例):
?xml version="1.0" encoding="UTF-8"?>
<manifest>
<remote name="origin" fetch="https://github.com/<account_name>/" review="https://github.com/<account_name>" />
<default revision="master" remote="origin" sync-j="4" />
<project path="source/security" name="security" />
<project path="source/safety" name="safety" />
<project path="source/slt" name="slt" />
</manifest>
然后上传manifest.xml.
manifest具体标签含义 可参考Link
四、管理代码
1. 创建projects目录,然后运行
repo init -u git@github.com:account_name/manifest.git -b master --repo-url=https://mirrors.tuna.tsinghua.edu.cn/git/git-repo/
2. repo sync (首次sync可能需要输入github账号和密码)
3. repo start master --all
这样就能下载整个项目的代码了。
总结
参考文档