windows下使用repo和gitlab的代码管理系统

参考博文:

Manifest和Repo使用详解
Ubuntu20.04 搭建repo + gitlab的代码管理系统
版本管理之将gitlab仓进行repo整改

知识点

.repo/repo/repo sync -c --no-tags   //可以不下载 tag,加速代码同步

gitlab服务器端配置

在同一个group下添加 manifest仓库,以及对应的board app common 仓库,

<?xml version="1.0" encoding="UTF-8"?>
<manifest>
 <remote  name="Max" fetch="ssh://git@192.168.0.224"/>

<default remote="Max" revision="main" sync-j="4" />

<project name="rk_rv1103/board" path="board" remote="Max"/>
<project name="rk_rv1103/app" path="app" remote="Max"/>
<project name="rk_rv1103/common" path="common" remote="Max"/>
</manifest>

注意:如果按照Ubuntu20.04 搭建repo + gitlab的代码管理系统的方式设置成如下:

<project name="Max/rk_rv1103/board" path="board" remote="Max"/>
<project name="Max/rk_rv1103/app" path="app" remote="Max"/>
<project name="Max/rk_rv1103/common" path="common" remote="Max"/>

以上方式在init时不会出错,但是在同步时会报错,无法fetch.

客户端配置

在指定的文件夹下通过gitbash执行命令:

repo init -u git@192.168.0.224:rk_rv1103/manifest.git  -b main --repo-url=https://gerrit-googlesource.proxy.ustclug.org/git-repo

注意,manifest仓库地址如果设置成 ssh://git@192.168.0.224:rk_rv1103/manifest.git 会出错。

init仓库成功:

repo has been initialized in D:\RK_workspace\repo_test
Downloading Repo source from https://gerrit-googlesource.proxy.ustclug.org/git-repo

客户端同步

windows下安装repo

  1. 环境准备
    • 安装Git for Windows,360软件管家里可以直接搜到64位的git for windows。

    • 安装Python 2.7,360软件管家里可以直接搜到Python 2.7。
      撰文时最新python2 python2.7.18下载地址

    • 配置系统环境变量,Git 和python加入到环境变量。

  2. 安装repo
    • gitbash下clone git-repo
    • 将git-repo/下的repo文件拷贝到用户目录下,步骤:1.mkdir ~/bin;2. explore .;3.拷贝repo文件到打开的文件夹
    • 添加~/bin文件目录到path环境变量

文件同步

repo sync

同步成功
$ repo sync
repo sync has finished successfully.

repo sync报错的坑

$ repo sync
error: The following untracked working tree files would be overwritten by checkout:
        README.md
        app.c
Please move or remove them before you switch branches.
Aborting
app/: leaving master; does not track upstream
error: app/: rk_rv1103/app checkout 514ef09e5d64792a68fa5798c068ba3b54ad02d3
error: Cannot checkout rk_rv1103/app
error: The following untracked working tree files would be overwritten by checkout:
        README.md
Please move or remove them before you switch branches.
Aborting
board/: leaving master; does not track upstream
error: board/: rk_rv1103/board checkout 144bdc33ff1c1bb0cede2d766b9c5f0b89d5f36b
error: Cannot checkout rk_rv1103/board
error: The following untracked working tree files would be overwritten by checkout:
        README.md
Please move or remove them before you switch branches.
Aborting
common/: leaving master; does not track upstream
error: common/: rk_rv1103/common checkout 772750709ee1f7b0d8bc5282a889a7d51b742d2d
error: Cannot checkout rk_rv1103/common

error: Unable to fully sync the tree.
error: Checking out local projects failed.
Failing repos:
app
board
common
Try re-running with "-j1 --fail-fast" to exit at the first error.

  • 解决办法,删除每个仓库下的.git文件夹,重新repo init 再次同步

个人思考

  1. 博文只能做参考,可能因为配置环境的问题,例如系统的差别,会导致一些配置会有出入,需要思考甄别。
  2. 因为版本的原因会导致配置不一样。
  3. 因为repo是依赖pyhton2运行的程序,所以必须安装python2
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值