1、ssh-key
(1)出错信息:
正克隆到 'test-project1'...
Agent admitted failure to sign using the key.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
(2)解决方法:在当前用户下执行ssh-add
2、git提交出错
(1)命令:git push origin develop : develop
(2)出错信息:
error: dst ref refs/heads/develop receives from more than one src.
error: 无法推送一些引用到 'ssh://***@103.10.86.30:29418/test-project1'
(3)解决办法:将develop和冒号之间的空格去掉
3、gerrit的更新没有同步到gitlab:
除了检查权限配置以外,还需检查以下步骤:
1)用gerrit用户添加.gitreview文件
[root@localhost~]# su - gerrit
[gerrit@localhost ~]$ gitclone git@103.10.86.30:dev-group/test-project1.git
[gerrit@localhost~]$ cd test-project1
[gerrit@localhost test-project1]$ vim.gitreview
[gerrit]
host=103.10.86.30
port=29418
project=test-project1.git
2)添加.gitreview到版本库
[gerrit@localhosttest-project1]$ git add .gitreview
[gerrit@localhosttest-project1]$ git commit .gitreview -m 'add .gitreview file bygerrit.'
[gerrit@localhost test-project1]$ git push origin master
3)用gerrit用户在Gerrit上创建test-project1项目:
Projects->CreateNew Project,创建test-project1
4)将远程Gitlab上的test-project1项目发布到Gerrit
[gerrit@localhost~]$ cd /home/gerrit/gerrit_site/git/
[gerrit@localhost git]$ rm -rftest-project1.git
[gerrit@localhost git]$ git clone --baregit@103.10.86.30:dev-group/test-project1.git
5)同步Gerrit的test-project1项目到Gitlab
[gerrit@localhost~]$ cd /home/gerrit/gerrit_site/etc/
[gerrit@localhost etc] vimreplication.config
[remote"test-project1"]
projects = test-project1
url =git@103.10.86.30:dev-group/test-project1.git
push =+refs/heads/*:refs/heads/*
push = +refs/tags/*:refs/tags/*
push= +refs/changes/*:refs/changes/*
threads = 3
6)重新启动Gerrit服务:
[gerrit@localhost~]$ /home/gerrit/gerrit_site/bin/gerrit.sh restart
4、gerrit数据库登陆、查询、删除:
su - gerrit
1)停用gerrit
/home/gerrit/gerrit_site/bin/gerrit.sh stop
cd /home/gerrit/gerrit_site/
2)登陆数据库
java -jar bin/gerrit.war gsql
3)查找change id
select * from PATCH_SETS;
4)删除数据(change id栏为你需要删除行的change id)
delete from PATCH_SETS where change_id=3;
分支合并导致gerrit审核出错
[user@localhost~]$ cd test-project1/
[user@localhost test-project1]$ gitbranch develop //创建分支develop
[user@localhost test-project1]$ git pushorigin develop: develop
[user@localhost test-project1]$ gitcheckout develop //切换分支
[user@localhost test-project1]$ touchbr-file
[user@localhost test-project1]$ git add.
[user@localhost test-project1]$ gitcommit -m "add br-file for testing branch"
[user@localhost test-project1]$ git pushorigin HEAD:refs/for/develop //提交到Gerrit进行代码审查
如果此处没有等到代码审查结束就直接切换到master分支进行合并,gerrit审核通过submit的时候就会报错
[user@localhost test-project1]$ gitcheckout master
[user@localhost test-project1]$ gitmerge --no-ff develop //将develop分支合并到master
[user@localhost test-project1]$ git pushorigin //上传
5、[user@localhost ~]$ git clone git@192.168.0.1:dev-group/test-project1.git会需要密码,是需要先执行以下操作:
1、上传用户公钥到gitlab上;
2、在本地设置全局变量:
git config --global user.name "user"
git config --global user.email "user@126.com"
之后再执行操作即可