一、Gerrit过滤方法
1.查看某个文件已经merge的提交记录
file:autosleep.c status:merged
2.查看某个人已经merge的提交记录
owner:"my_name<my_email>" status:merged
二、Gerrit操作
1. repo工程拉单个版本库的方法
$ cat ./repo/projects/android/kernel/configs.git/config
[remote "origin"]
url = ssh://xxxxxxxxxx/kernel/configs
review = http://gerrit.xxxxxxx
$ git clone ssh://xxxxxxxxxx/kernel/configs
2. Gerrit本地提交方法
格式:git push origin HEAD:refs/for/分支名 前提条件是本地也需要处于同一分支中
3. 代码审核失败后,重新提交时必须使用 git commit --amend,否则会生成新的评审任务,无法与上一次审核任务关联。
测试git commit --amend的重新提交的虽然commit hash会变,但是Change-Id是不会变的。
4. 点击左上方的菜单栏Projects->List,就能看到gerrit仓库里面所有的项目,排在最前的两个默认项目All-Projects和 All-Users,这两个工程是两个基础的工程,我们后期新建的所有项目默认都是继承
自ALL-Projects的权限。
5.使用Gerrit拉单个仓库代码的方法
git clone ssh://<your name>@gerrit.codebase.scm.adc.com:29411/sba_patches -b private_LA.UM.8.12_20200924221525 git clone ssh://<your name>@gerrit.scm.adc.com:29411/<project path name> -b <branch name>
6. Gerrit上下载的.diff格式的补丁可以直接使用git apply进行打,不需要使用patch命令打补丁。
7. Gerrit提交冲突了,使用 git pull --rebase 后,重新提交。
8. 只拉单个仓库的代码
git clone ssh://<your_gerrit_name>@<服务器仓库>:29418/<仓库名> -b <分支名>
三、Gerrit 加key
没有key报错如下:
$ git clone ssh://xiaoming@192.168.10.112:29418/perfermance Cloning into 'perfermance'... Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
表示没有对 192.168.10.112 这个服务器加 public key。
加 key 方法:
(1) 浏览器打开 http://192.168.10.112:8080,然后在左上角自己名字下面点击 setting --> "SSH Public Keys" --> Add Key。
(2) $ cat ~/.ssh/id_rsa.pub 将打印出来的内容添加到上一步骤的 Add Key 框里,点击add,之后就有权限clone代码了。
其中 29418 是默认的 Gerrit ssh 端口,而 8080 是默认的 Gerrit Web 端口。