在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

相关推荐
软件技术NINI2 小时前
娃娃店html+css 4页
前端·css·html
wordbaby2 小时前
TanStack Router 路径参数(Path Params)速查表
前端
盟接之桥3 小时前
盟接之桥--说制造:从“找缝隙”到“一万米深”——庖丁解牛式的制造业精进之道
大数据·前端·数据库·人工智能·物联网·制造
巴拉巴拉~~3 小时前
Flutter 通用滑块组件 CommonSliderWidget:单值 / 范围 + 刻度 + 标签 + 样式自定义
开发语言·前端·javascript
韭菜炒大葱3 小时前
现代前端开发工程化:Vue3 + Vite 带你从 0 到 1 搭建 Vue3 项目🚀
前端·vue.js·vite
栀秋6664 小时前
面试常考的最长递增子序列(LIS),到底该怎么想、怎么写?
前端·javascript·算法
Melrose4 小时前
Flutter - 使用Jaspr来构建SEO友好网站
前端·flutter
有点笨的蛋4 小时前
Vue3 项目:宠物照片变身冰球运动员的 AI 应用
前端·vue.js
盖头盖4 小时前
【nodejs中的ssrf】
前端
江城开朗的豌豆4 小时前
TypeScript和JavaScript到底有什么区别?
前端·javascript