参考博文:
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
- 环境准备
-
安装Git for Windows,360软件管家里可以直接搜到64位的git for windows。
-
安装Python 2.7,360软件管家里可以直接搜到Python 2.7。
撰文时最新python2 python2.7.18下载地址文章来源:https://www.toymoban.com/news/detail-624875.html -
配置系统环境变量,Git 和python加入到环境变量。文章来源地址https://www.toymoban.com/news/detail-624875.html
-
- 安装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 再次同步
个人思考
- 博文只能做参考,可能因为配置环境的问题,例如系统的差别,会导致一些配置会有出入,需要思考甄别。
- 因为版本的原因会导致配置不一样。
- 因为repo是依赖pyhton2运行的程序,所以必须安装python2
到了这里,关于windows下使用repo和gitlab的代码管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!