笔记-使用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"
相关推荐
钱栈up6 小时前
GitHub 热榜上手|Orca:让多个编码 Agent 并排跑
github
wflynn11 小时前
GitHub 日榜趋势速报 | 2026-11-02
开源·github
徐小夕12 小时前
深度剖析 30k star 的编码 Agent DeepSeek-Reasonix:长会话 Token 成本直降 80%
前端·vue.js·github
Iron_12 小时前
多平台内容分发的适配器
github
u13013012 小时前
GitHub 热榜项目:日榜(2026-11-02)
人工智能·github
Sakura_j_h_13 小时前
GitHub Actions 打包 Windows exe:中文编码与产物上传
windows·ci/cd·打包发布·github·pyinstaller·github actions
miofly13 小时前
Meta 816B 参数 Muse Spark Open 在 NVIDIA GB300 上实现每 GPU 50K tokens 每秒
开源·github
全栈陈序员13 小时前
【Git】从入门到精通(一)—— Git简介:什么是版本控制系统
大数据·git·elasticsearch
dong_junshuai14 小时前
每天一个开源项目#148 T3 Code:把代理会话与代码工作区分开管理
github