笔记-使用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"
相关推荐
小兵张健2 小时前
Playwright MCP 截图标注方案调研(推荐方案1)
前端·javascript·github
哈基咪怎么可能是AI5 小时前
为什么我就想要「线性历史 + Signed Commits」GitHub 却把我当猴耍 🤬🎙️
linux·github
vibecoding日记21 小时前
为什么我就想要「线性历史 + Signed Commits」,GitHub 却把我当猴耍 🤬🎙️
git·编程工具
九狼1 天前
Flutter URL Scheme 跨平台跳转
人工智能·flutter·github
逛逛GitHub1 天前
4 个热门的 GitHub 开源项目
github
程序员鱼皮1 天前
GitHub 关注突破 2w,我总结了 10 个涨星涨粉技巧!
前端·后端·github
程序员小崔日记1 天前
如何将代码轻松上传到 Gitee?Git 使用全攻略!
git·gitee·上传