您的位置:首页 > 其它

LDAP + redmine + gerrit + jenkins + gitlab -- 添加已有git仓库到gerrit

2017-12-07 23:14 465 查看

环境

gerrit上已有两个账号, shuhm和temp, 其中shuhm为管理员

testgerrit为本地git仓库

配置gerrit发送邮件

编辑
gerrit_site/etc/gerrit.config
, 其中gerrit_site为gerrit的安装目录

[sendemail]
smtpServer = smtp.263.net
smtpServerPort = 587
#smtpEncryption = ssl
smtpUser = shuhm@r7data.com
smtpPass = xxxxxx
sslVerify = false
from=CodeReview<gerrit@r7data.com>


创建Project

先通过gerrit web 创建Project, test

添加本地git仓库

通过管理员账号将已有git仓库推到gerrit

→ testgerrit (master) git push -u ssh://shuhm@172.16.6.220:29418/test.git master

clone gerrit 仓库

普通账号将仓库从gerrit clone到本地

→ git clone ssh://temp@172.16.6.220:29418/test.git

→ test (master) ls

README.md

修改README.md, 并commit

→ test (master) echo "world" >> README.md
→ test (master) git add README.md
→ test (master) git commit -m "add world"
[master 580bc0e] add world
Committer: Kylin <kylin@localhost.localdomain>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly. Run the
following command and follow the instructions in your editor to edit
your configuration file:

git config --global --edit

After doing this, you may fix the identity used for this commit with:

git commit --amend --reset-author

1 file changed, 1 insertion(+)


push到gerrit

→ test (master) git push ssh://temp@172.16.6.220:29418/test.git
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 261.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Branch refs/heads/master:
remote: You are not allowed to perform this operation.
remote: To push into this reference you need 'Push' rights.
remote: User: temp
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.16.6.220:29418/test.git
! [remote rejected] master -> master (prohibited by Gerrit: ref update access denied)
error: failed to push some refs to 'ssh://temp@172.16.6.220:29418/test.git'


配置
remote.origin.push
, 再次push

→ test (master) git config remote.origin.push refs/heads/*:refs/for/*

→ test (master) git push ssh://temp@172.16.6.220:29418/test.git HEAD:refs/for/master
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 261.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
remote:
remote: ERROR:  In commit 580bc0ebae7f7e752b25e9c7ba0b405c37897d61
remote: ERROR:  committer email address kylin@localhost.localdomain
remote: ERROR:  does not match your user account.
remote: ERROR:
remote: ERROR:  You have not registered any email addresses.
remote: ERROR:
remote: ERROR:  To register an email address, please visit:
remote: ERROR:  http://172.16.6.220:9080/#/settings/contact remote:
remote:
To ssh://172.16.6.220:29418/test.git
! [remote rejected] HEAD -> refs/for/master (invalid committer)
error: failed to push some refs to 'ssh://temp@172.16.6.220:29418/test.git'


配置Email, 再次push

登录gerrit web -> Settings -> Contact Information -> Register New Email … 然后登录邮箱进行验证

→ test (master) git config user.email 84567012@qq.com

→ test (master) git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 261 bytes | 261.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
remote:
remote: ERROR:  In commit 580bc0ebae7f7e752b25e9c7ba0b405c37897d61
remote: ERROR:  committer email address kylin@localhost.localdomain
remote: ERROR:  does not match your user account.
remote: ERROR:
remote: ERROR:  The following addresses are currently registered:
remote: ERROR:    84567012@qq.com
remote: ERROR:
remote: ERROR:  To register an email address, please visit:
remote: ERROR:  http://172.16.6.220:9080/#/settings/contact remote:
remote:
To ssh://172.16.6.220:29418/test.git
! [remote rejected] master -> refs/for/master (invalid committer)
error: failed to push some refs to 'ssh://temp@172.16.6.220:29418/test.git'


更正comment, 再次push

→ test (master) git log
commit 580bc0ebae7f7e752b25e9c7ba0b405c37897d61 (HEAD -> master)
Author: Kylin <kylin@localhost.localdomain>
Date:   Thu Dec 7 21:15:31 2017 +0800

add world

→ test (master) git commit --amend

→ test (master) git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 281 bytes | 281.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: refs: 1, done
remote: ERROR: [f7916cd] missing Change-Id in commit message footer
remote:
remote: Hint: To automatically insert Change-Id, install the hook:
remote:   gitdir=$(git rev-parse --git-dir); scp -p -P 29418 temp@172.16.6.220:hooks/commit-msg ${gitdir}/hooks/
remote: And then amend the commit:
remote:   git commit --amend
remote:
To ssh://172.16.6.220:29418/test.git
! [remote rejected] master -> refs/for/master ([f7916cd] missing Change-Id in commit message footer)
error: failed to push some refs to 'ssh://temp@172.16.6.220:29418/test.git'


添加hook, 再次push

→ test (master) gitdir=$(git rev-parse --git-dir); scp -p -P 29418 temp@172.16.6.220:hooks/commit-msg ${gitdir}/hooks/
commit-msg                                                                                                                  100% 4693     3.1MB/s   00:00

→ test (master) git commit --amend

[master df26fa4] add world
Author: Kylin <kylin@localhost.localdomain>
Date: Thu Dec 7 21:15:31 2017 +0800
1 file changed, 1 insertion(+)

→ test (master) git push
Counting objects: 3, done.
Writing objects: 100% (3/3), 320 bytes | 320.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote:   http://172.16.6.220:9080/1 add world
remote:
To ssh://172.16.6.220:29418/test.git
* [new branch]      master -> refs/for/master
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: