git-review安装
apt-get install git-review # ubuntu
yum install git-review # centos
pip install git-review # python方式安装
git-review配置
添加gerrit用户名
git config --global gitreview.username gerritadmin
代码工程添加 .gitreview配置文件
.gitreview
[gerrit]
host=192.168.3.57
port=29418
project=mec-demo
defaultbranch=dev
提交代码
新增代码
gerrit@node-33:~/gerrit/mec-demo$ git add .
gerrit@node-33:~/gerrit/mec-demo$ git status
On branch test
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
new file: test123
gerrit@node-33:~/gerrit/mec-demo$ git commit -m "new file"
[test 3f7515b] new file
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test123
# 每次提交前都要和要提交到的分支对齐,有冲突的话需要解决冲突
gerrit@node-33:~/gerrit/mec-demo$ git fetch origin dev:dev
gerrit@node-33:~/gerrit/mec-demo$ git rebase dev
Current branch review/unknown/test is up to date.
gerrit@node-33:~/gerrit/mec-demo$ git review -c -v
patch 代码
在原分支上
gerrit@node-33:~/gerrit/mec-demo$ git branch
dev
* test
gerrit@node-33:~/gerrit/mec-demo$ git status
On branch test
nothing to commit, working directory clean
gerrit@node-33:~/gerrit/mec-demo$ echo "test" >> test123
gerrit@node-33:~/gerrit/mec-demo$ git status
On branch test
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test123
no changes added to commit (use "git add" and/or "git commit -a")
gerrit@node-33:~/gerrit/mec-demo$ git add .
gerrit@node-33:~/gerrit/mec-demo$ git commit --amend
# 每次提交前都要和要提交到的分支对齐,有冲突的话需要解决冲突
gerrit@node-33:~/gerrit/mec-demo$ git fetch origin dev:dev
gerrit@node-33:~/gerrit/mec-demo$ git rebase dev
Current branch review/unknown/test is up to date.
gerrit@node-33:~/gerrit/mec-demo$ git review -c -R -v
.......
To ssh://gerritadmin@192.168.3.57:29418/mec-demo
* [new branch] HEAD -> refs/for/dev/test
新建临时分支
gerrit上找到Change-Id
image.png
gerrit@node-33:~/gerrit/mec-demo$ git review -d Idda29b220f08fe2dc5bf3afcec2cc57b17daeb56
Downloading refs/changes/04/4/2 from gerrit
Switched to branch "review/unknown/test"
### 重复以上操作
网友评论