【repo系列】repo常用命令的使用

前言

repo是一种代码版本管理工具,它是由一系列的Python脚本组成,封装了一系列的Git命令,用来统一管理多个Git仓库。
本文章描述repo常用命令的使用。

常用命令

初始化

repo init

初始化代码仓

repo init [options]

常用options:
-u URL, --manifest-url=URL manifest repository location
-b REVISION, --manifest-branch=REVISION manifest branch or revision
-m NAME.xml, --manifest-name=NAME.xml initial manifest file
-g GROUP, --groups=GROUP restrict manifest projects to ones with specified
–no-clone-bundle disable use of /clone.bundle on HTTP/HTTPS
–no-tags don’t fetch tags in the manifest
–no-repo-verify do not verify repo source code
–repo-branch=REVISION repo branch or revision
例如:

repo init -u http://xxx.com/xxx.git -b master -m default.xml -g release --no-repo-verify --repo-branch=stable_py3
repo sync

同步代码仓
需要注意的是,如果sync之前,代码仓已拉取,甚至子仓切过branch,更新代码时需要保证是同一branch名称。

repo sync

常用options:
-c, --current-branch fetch only current branch from server
-q, --quiet be more quiet
-j JOBS, --jobs=JOBS projects to fetch simultaneously (default 16)
–no-tags don’t fetch tags
例如

repo sync -c --no-tags -j 64
repo start

为当前仓建一个分支

repo start <newbranchname> [--all | <project>...]

常用options:
–all begin branch in all projects
例如:

repo start br_test -all

查询

repo status

查询当前代码仓中的分支

repo status

返回信息为

project app/     branch br_test
project test/    branch br_test
...
repo list

查看当前代码仓路径及名称

repo list

返回信息为

source/app : app
source/test : test
source/zlib : zlib
source/openssl : openssl
...
repo info

查看当前各仓的信息

repo info

返回信息为

Manifest branch: master
Manifest merge branch: refs/heads/master
Manifest groups: release
----------------------------
Project: app
Mount path: /home/xxx/master/source/app
Current revision: xxxx51d10exxxx43b39a7xxxx036a374be89xxxx
Current branch: br_test
Manifest revision: release
Local Branches: 1 [br_test]
----------------------------
Project: test
Mount path: /home/xxx/master/source/test
Current revision: xxxx61d10exxxx43b39a7xxxx036a374be89xxxx
Current branch: br_test
Manifest revision: release
Local Branches: 1 [br_test]
----------------------------
...
repo branch
repo branch

返回信息为

*  br_test                    | in:
                                   zlib
                                   openssl
                                   test
                                   ...
                                   app
   br_delete                  | in app
*  br_modify                  | in app

从返回信息可以看出,
当前仓内,除了app子仓,均只有一个分支br_test,且处于该分支;app子仓共有br_test、br_delete、br_modify3个分支,当前处于br_modify分支。

repo branches

同 repo branch

修改

repo upload

将当前修改提交到远程分支上。
需要注意的是,提交代码时需要保证各仓是同一branch名称。

repo upload

或单独进入某一子仓

repo upload ./
repo forall

为当前各子仓执行同一命令

repo forall

常用options:
-c, --command Command (and arguments) to execute
-p Show project headers before output

例如:

repo forall -c "git reset --hard HEAD"

回退各子仓代码。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值