Repo简介

Repo官方

repo - The Multiple Git Repository Tool

Repo安装

$ mkdir ~/bin

$ PATH=~/bin:$PATH

$ curl https://storage.googleapis.com/git-repo-downloads/repo > ~/bin/repo

$ chmod a+x ~/bin/repo

$ repo init -u ssh://yourname@gerrit.huami.com:29418/manifest -b master -m manifest.xml

$ repo sync

repo常见命令:

1)生成当前版本manifest

repo manifest -r --suppress-upstream-revision -o manifest_xxx.xml

或者

repo manifest -o ABC.xml -r

2)在不丢失本地修改的情况下,同步代码

repo sync -d

如果本地修改了代码但还没有 commit,会提示无法 sync,加上 -d 选项只表示忽略本地改动。

3)强制同步

repo sync --force-sync

本地修改会丢失

4)撤销本地代码修改

repo forall -c "git clean -df" && repo forall -c "git checkout ."

5)所有仓库创建master分支

repo start forall master

6)遍历所有的仓库,清除本地修改

repo forall -c git git reset --hard HEAD

7)添加环境变量

repo forall –c ‘echo $REPO_PROJECT’

8)repo manifest

显示manifest文件内容

9) repo grep

在项目文件中进行内容查找

10)工程init & 同步代码

repo init -u ssh://xxxxxxxx@gerrit.huami.com:29418/manifest -b master -m manifest.xml

repo sync

11)库上代码回退

repo forall -c 'commitID=git log --before "2021-02-21 08:00" -1 --pretty=format:"%H"; git reset --hard $commitID'

12)通过xml配置文件回退代码

repo init -m dev.xml

repo sync