Gerrit提code的流程

一、前期准备

  • 注册

  • 配置

$ git config --global user.name "Firstname Lastname"
$ git config --global user.email "your_email@youremail.com"
  • pip安装git-review

$ pip install git-review
  • 添加ssh密钥

1). 备份.ssh (如果存在):

myubuntu@host:~$ cp -r ~/.ssh ~/.ssh_bak

2). 生成密钥:

myubuntu@host:~$ rm -rf ~/.ssh
myubuntu@host:~$ ssh-keygen -t rsa -C "gerrit上的注册邮箱"
myubuntu@host:~$ cat ~/.ssh/id_rsa.pub

复制该公钥到gerrit的setting中

3). 添加到ssh-agent中

  • start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
Agent pid 59566
  • add your SSH private key to the ssh-agent.
$ ssh-add ~/.ssh/id_rsa

4). 测试

$ ssh -T git@github.com
Hi Iruze! You've successfully authenticated, but GitHub does not provide shell access.

或参考:https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

二、工作流程

  • 获取项目代码
myubuntu@host:~$ git clone git://github.com/openstack/nova.git
myubuntu@host:~$ cd nova
  • 创建版本库
$ git init
Initialized empty Git repository in /Users/michael/learngit/.git/
  • 检查git-review是否可以提交review
myubuntu@host:~$ git review -s

测试29418端口是否可以通信

$ ssh -vv -p 29418 xxx@review.openstack.org
  • 如果没有添加远程仓库
myubuntu@host:~$ git remote add gerrit ssh://**"username"**@review.openstack.org:29418/openstack/nova.git
myubuntu@host:~$ git remote -v

(git remote remove origin 移除源,或许用到)

  • 创建新的分支,在其上修改,之后提交
myubuntu@host:~$ git checkout -b "dev"
myubuntu@host:~$ git status

(…修改xxx文件之后…)
(在cd nova最外层文件内)

myubuntu@host:~$ git status
myubuntu@host:~$ git add xxx
myubuntu@host:~$ git commit -m "fix yyy problem in xxx file"
  • tox检查提交
    如果是上次提交的一个patch:
myubuntu@host:~$ git commit --amend

myubuntu@host:~$ tox -v #(check code)
(or maybe ) tox -e pep8/py27/py35/py36/docs

最终正式提交

myubuntu@host:~$ git review [branch_name]

三、其他错误

1)无法ping通github.com
解决:

  • vi /etc/hosts
  • 在最后添加:
192.30.253.113 github.com 
192.30.252.131 github.com 
185.31.16.185 github.global.ssl.fastly.net 
74.125.237.1 dl-ssl.google.com 
173.194.127.200 groups.google.com 
192.30.252.131 github.com 
185.31.16.185 github.global.ssl.fastly.net 
74.125.128.95 ajax.googleapis.com

Reference:
Gerrit工作流程:
https://blog.csdn.net/Shatty/article/details/10200207
Gerrit使用简介:
https://www.cnblogs.com/lexuele/p/5133601.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值