笔记-使用Repo工具管理多个关联仓库(适用于复杂项目)

笔记-使用Repo工具管理多个关联仓库(适用于复杂项目)

Repo工具通过一个manifest文件统一管理多个Git仓库,常用于Android等大型项目。

1. 安装Repo工具

下载Repo引导脚本并配置镜像源(以清华大学镜像为例):

cpp 复制代码
curl https://mirrors.tuna.tsinghua.edu.cn/git/git-repo > /usr/local/bin/repo
chmod +x /usr/local/bin/repo
export REPO_URL='https://mirrors.tuna.tsinghua.edu.cn/git/git-repo'
2. 创建Manifest仓库

初始化一个裸仓库作为中心仓库:

cpp 复制代码
git init --bare manifest.git

创建default.xml文件,定义子仓库路径和远程源:

cpp 复制代码
<?xml version="1.0" encoding="UTF-8"?>
<manifest>
    <remote name="origin" fetch="ssh://user@server:/path/to/repos"/>
    <default remote="origin" revision="master"/>
    <project path="module1" name="module1.git"/>
    <project path="module2" name="module2.git"/>
</manifest>

提交并推送default.xml:

cpp 复制代码
cd manifest.git
git add default.xml
git commit -m "Initial manifest"
git push origin master
3. 客户端初始化

在本地创建工作目录并初始化Repo:

bash 复制代码
mkdir myproject && cd myproject
repo init -u ssh://user@server:/path/to/manifest.git

同步所有子仓库:

bash 复制代码
repo sync
4. 推送代码到服务器

若需将本地修改推送到中心仓库,需通过repo forall批量操作:

bash 复制代码
repo forall -pv -c "git push origin master"
相关推荐
fthux9 小时前
装闭 RenoPit 源码解析(07):装修闭坑知识库与AI Prompt构建
人工智能·ai·开源·github·open source·renopit
fthux12 小时前
装闭 RenoPit 源码解析(06):SSE如何实时推送AI装修分析进度
人工智能·ai·开源·github·open source·renopit
是烨笙啊14 小时前
拯救 GitHub stars 体验:从 Agent Skill 到浏览器插件
github
小弥儿15 小时前
GitHub今日热榜 | 2026-08-11:图原生基础设施首日登顶
学习·开源·github
码流怪侠16 小时前
用 WiFi 信号数人头:howmanypeoplearearound 项目深度解析
后端·开源·github
大强同学18 小时前
零成本部署0penList,三步搞定,我一分钱没花!
github
71777718 小时前
数据与专家双驱动:Gitee 开源项目智能推荐体系与选型实践
gitee·开源
IT摆渡者1 天前
VM EXSI7.0存储硬盘故障处理
大数据·linux·github
Narrastory1 天前
我用 Claude Code 写代码不到 2 小时,却花了 3 天做完这个软件—Vibe Coding 的正确姿势,是设计不是生成
前端·人工智能·github
AI Dog1 天前
GitHub 项目整体替换与大文件处理指南
github