参考资料
Gerrit工作流程及使用手册
环境配置
生成ssh key
ssh-keygen -t rsa -C "youremail@example.com"
路径如下
/Users/zhouqirui/.ssh/id_rsa
更改系统SSH配置
//路径
sudo nano /etc/ssh/ssh_config
//增加如下内容
MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
HostkeyAlgorithms ssh-dss,ssh-rsa
KexAlgorithms +diffie-hellman-group1-sha1
配置 Gerrit Web SSH
![](https://static.oschina.net/uploads/img/201711/22235237_Fohu.png)
git clone 路径 (建议用终端clone 用sourcetree 还要手动配置 hooks)
![](https://static.oschina.net/uploads/img/201711/22235422_rLM5.png)
git配置
//项目根目录下配置GIT
git config remote.origin.push refs/heads/*:refs/for/*
自定义Push (sourcetree 自带PUSH不能使用,暂时没解决办法)
![](https://static.oschina.net/uploads/img/201711/22235444_wJaZ.png)
// 使用 git push
// 备注: (可以使用,但多分支下,回报错)
YW20170821003:IOS zhouqirui$ git push
Total 0 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 2, done
To ssh://172.18.200.198:29418/IOS
! [remote rejected] feature/raychow_develop -> refs/for/feature/raychow_develop (no new changes)
! [remote rejected] master -> refs/for/master (duplicate request)
error: failed to push some refs to 'ssh://zhouqirui@172.18.200.198:29418/IOS'
// 使用 git push origin HEAD:refs/for/master
// 备注: 一直报错..
YW20170821003:IOS zhouqirui$ git push origin HEAD:refs/for/master
Total 0 (delta 0), reused 0 (delta 0)
remote: Branch refs/heads/refs/for/master:
remote: You are not allowed to perform this operation.
remote: To push into this reference you need 'Push' rights.
remote: User: zhouqirui
remote: Please read the documentation and contact an administrator
remote: if you feel the configuration is incorrect
remote: Processing changes: refs: 1, done
To ssh://172.18.200.198:29418/IOS
! [remote rejected] HEAD -> refs/for/master (prohibited by Gerrit)
error: failed to push some refs to 'ssh://zhouqirui@172.18.200.198:29418/IOS'
//使用 git-review 代替,见下问
使用
Gerrit 审核参考 (需要有权限)
![](https://static.oschina.net/uploads/img/201711/22235515_AwV1.png)
审核不过(处理)
![](https://static.oschina.net/uploads/img/201711/22235550_4Lsi.png)
'更正上一次提交' 选项
该用法确保使用上一次记录重新提交,使用上次生成唯一 commit ID
合并commit
//1.最近2条记录
git rebase -i HEAD~2
//2.合并改写 (退出命令 esc :wq)
pick b0f97ef7d c1
squash a61e4a8fb c2
# Rebase 8df25e817..a61e4a8fb onto 8df25e817 (2 commands)
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
//3. 查看记录
git log
//4.正常提交
上传方法1 - (git push 带参数)
使用原因
推荐使用这个办法配置 sourectree 快捷操作做处理。路径必须指定对应分支,格式如下:
git push ssh://zhouqirui@192.168.31.65:29418/IOS HEAD:refs/for/develop
上传方法2 - (git-review 安装与配置)
使用原因
网上提示使用如下作提交,然而本人测试无论如何都无法单个分支提交成功.所有找了 git-review 替代 git push
git push origin HEAD:refs/for/master
安装
参考
brew install git-review
配置命令配置
//新建文件
nano .gitreview
//设置
git review -s
//使用 在要提交的分支下使用,并且配置文件要统一,有错误就按提示做处理就可以了.
git review
//等待审核
配置文件
[gerrit]
host=172.18.200.198
port=29418
project=IOS
defaultbranch=master ## 这个路径要对应不同仓库处理
更详细说明请点击