在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

相关推荐
鶴哥只手遮天1 分钟前
《Electron 45.2.3 内核解剖》第 4 章 补丁体系:380 个补丁改了什么
前端·electron
FungLeo2 小时前
成为全栈·Vue 管理后台篇·分类树与标签管理:层级数据如何落到管理界面
前端·javascript·vue.js·分类树·naive ui·标签管理·前端数据结构
Lank_M6 小时前
白底都占八成,PNG 为何只在图表页赢过 JPG
前端
张一凡936 小时前
给 Coding Agent 加一道"架构闸门":Jin 是如何做到"先审架构、再写代码、不漂移"的
前端·后端·agent
Linye6 小时前
AI 写的 HTML 原型全是空壳?聊聊真实 DOM 交互避坑
前端·人工智能
ZANE6 小时前
纯前端实现的 PDF 与图片互相转换工具技术实现
前端
Swot6 小时前
SvelteKit Remote Functions 使用指南
前端·后端
Cooper256 小时前
三源热榜去重加 AI 摘要:URL 唯一键踩出的三个坑
前端·python
Yk酱228407 小时前
A2UI探索随笔-技术选型
前端
前端繁华如梦7 小时前
# 从 73000 行压缩代码到 TypeScript 模块化:我把一个 Three.js FPS 游戏 1:1 复刻了一遍
前端