前言
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:zlibopenssltest...appbr_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"
回退各子倉代碼。