在Windows上 安装使用repo

一、repo简介

一个大型项目通常会有多个仓库构成,比如 Android 项目,通过 manifest 清单(xml 文件)定义一个项目中各个 git 代码仓库的关联,而 repo 就是在这种项目组织方式下的一个用于多仓库协同开发和代码评审的一个客户端工具。

repo 是使用 python 开发实现的,需要安装 python 才能运行,repo 可以用于下载和提交代码,以及对多个代码仓库同时执行 git 命令,在他的官网上可以找到更多关于repo的介绍资料:https://gerrit.googlesource.com/git-repo/+/HEAD/README.md

二、Window系统安装使用repo

原始的 Google repo 工具仅支持在 Linux 系统下运行,现在支持 python 2 和 python 3,但无法在 Windows 上使用,这使得一些在 Windows 系统环境下开发的项目使用 repo 不太方便。

如果需要在Windows下使用,可以使用第三方的 esrlabs repo,按照官网介绍下载安装repo,并添加环境变量就可以使用了,目前仅支持 python2,esrlabs repo 的命令参数兼容原始的google repo,这算是 Windows 下使用 repo 的一个替代方案。如果使用的是 Windows 10,还可以在 Windows 10 的Linux 子系统下安装原始 repo,在 Linux 子系统进行多仓库管理,这是第二个方案。

第三个方案是使用 go 语言开发 git-repo 替代 repo,下面介绍 git-repo 的安装和使用。

三 git-repo安装与使用

git-repo 是一个使用 go 编写的仓库管理工具,与原始 repo 相比,支持 Windows、Mac 和 Linux 系统,除了git,没有其他软件依赖,兼容多数原始的 repo 命令,速度也比 python 编写的 repo 快,所以在 Windows 平台上 git-repo 算是一个很好的替代原始 repo 的选择,它的官网地址为:阿里git客户端工具,可以了解更多信息。

安装git-repo

首先去 下载 -- 阿里git客户端工具 下载对应平台的二进制执行文件,然后将其添加到环境变量。

需要说明的是,对于Windows系统,需要将git-repo.exe可执行文件拷贝到C:\Windows\System32目录下,然后将C:\Windows\System32\git-repo.exe添加到系统环境变量中,如下图所示。

然后,打开 git bash,能够正确执行 git repo version 命令说明安装好了。

复制代码
$ git repo version
git-repo version 0.7.8
git version 2.22.0.windows.1

基本使用

git-repo 在使用上是作为 git 的一个子命令 git repo 来使用的,在 git repo 后面输入命令参数。

初始化项目:git repo init -u < manifest-url>

复制代码
$ git repo init -u git@gitee.com:qioixiy/manifests.git
Warning: Permanently added the ECDSA host key for IP address '212.64.62.183' to the list of known hosts.
remote: Enumerating objects: 17, done.
remote: Total 17 (delta 0), reused 0 (delta 0), pack-reused 17
Unpacking objects: 100% (17/17), done.
From gitee.com:qioixiy/manifests
 * [new branch]      master     -> origin/master
Note: checking out '20dd4a7db47f19b7e59f4e880a46ac9732cd4986'.


You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.


If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:


  git checkout -b <new-branch-name>


HEAD is now at 20dd4a7 Add trac into dev-env
Switched to a new branch 'default'
NOTE: Your identity is: hacper <git>
NOTE: If you want to change this, please re-run 'git repo init' with --config-name
NOTE: repo has been initialized in G:\Workspace\fsl
</git></new-branch-name>

同步代码:git repo sync

复制代码
$ git repo sync
remote: Enumerating objects: 315, done.
remote: Enumerating objects: 6069, done.
remote: Total 315 (delta 0), reused 0 (delta 0), pack-reused 315
Receiving objects: 100% (315/315), 120.01 KiB | 278.00 KiB/s, done.
Resolving deltas: 100% (126/126), done.
From https://gitee.com/qioixiy/shell.profileiB | 262.00 KiB/s
 * [new branch]      master     -> gitee_qioixiy/master
remote: Total 6069 (delta 0), reused 0 (delta 0), pack-reused 6069
Receiving objects: 100% (6069/6069), 2.35 MiB | 497.00 KiB/s, done.
Resolving deltas: 100% (4069/4069), done.
From https://gitee.com/qioixiy/git-repo
 * [new branch]      main       -> gitee_qioixiy/main
 * [new branch]      master     -> gitee_qioixiy/master
ERROR: 404: bad ssh_info response of 'http://gitee.com/ssh_info'
NOTE: fail to check remote server, you may need to install gerrit hooks by hands
ERROR: fail to load remotes: gitee_qioixiy
Note: checking out 'd7399d9ca2cfe40dcee22f0ea6ce0cdd283e5a78'.


You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.


If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:


  git checkout -b <new-branch-name>


HEAD is now at d7399d9 update home_dot/files/.profile_priv.
Note: checking out '6a2f4fb39073a4e2e6824d5f2f4a1cbf5fe4b766'.


You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.


If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:


  git checkout -b <new-branch-name>


HEAD is now at 6a2f4fb repo init: Added --no-partial-clone and made it persist. Bumped version to 2.14.
</new-branch-name></new-branch-name>

创建新分支:git repo start --all new_branch_name

复制代码
$ git repo start --all fea/test
Switched to a new branch 'fea/test'
Switched to a new branch 'fea/test'

提交代码: git repo upload

相关推荐
大模型码小白5 小时前
数据可视化:AI处理多维数据的HTML5可视化方案
大数据·前端·javascript·人工智能·机器学习·信息可视化·html5
LabVIEW开发6 小时前
LabVIEW 前面板装饰图形的格式选择与自定义选板添加
前端·labview·labview知识·labview功能·labview程序
掘金者阿豪6 小时前
GPT-6 Astra 来了,GPT-5.6 Sol 还值得用吗?聊聊 Coding、百万上下文、价格和 Plus/Pro
前端·后端
code 小楊6 小时前
腾讯开源 WeKnora 深度解析:RAG 问答 + ReAct Agent 推理 + 自动 Wiki 图谱,三位一体的企业级知识中台
前端·人工智能·开源·知识图谱
roamingcode6 小时前
让 AI 的回答「逐段说话」:react-streaming 的顺序流式渲染实践
前端·人工智能·react.js·codex
cidy_986 小时前
Main 正式环境合并说明
前端
万物智能6 小时前
开源鸿蒙内核配置与驱动三条路径—【万物智能之开源鸿蒙OpenHarmony系统实战开发系列教程】
前端·后端
hunterandroid6 小时前
Android 多渠道打包与 Gradle 构建优化实战
android·前端·kotlin
cidy_987 小时前
Develop 测试环境合并说明
前端
用户252632753477 小时前
如何实现MySQL多表联查
前端