笔记-使用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"
相关推荐
Winlifes1 天前
我给 Codex 做了一个 Git 面板:分支树、提交历史和工作区操作
git
lpfasd1231 天前
2026年第38周GitHub趋势周报
python·科技·github
7177771 天前
研发平台选哪家比较好:2026年主流平台对比与Gitee选型指南
人工智能·gitee
u1301301 天前
GitHub 热榜项目:日榜(2026-09-21)
人工智能·github
张洛闻Eren1 天前
k8s云原生【第十课】:水平 Pod 自动扩缩容
运维·数据库·云原生·kubernetes·github
m4Rk_1 天前
【论文阅读】Agent 记忆机制(77):TSM——让记忆回到事件真正发生的时间
论文阅读·人工智能·学习·开源·github
橘和柠1 天前
依赖冲突:装个包装崩了项目,怎么排查和救回来
github
别动我齐刘海1 天前
ROS2 Jazzy + C++ 实战路线——ros2_control
c++·人工智能·python·opencv·机器学习·机器人·github
怕浪猫2 天前
ZCode 开源了来看看这是个什么东西
node.js·github·代码规范