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

来源:互联网 发布:免费钢材销售软件 编辑:程序博客网 时间:2024/06/07 05:34

环境

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 basedon your username and hostname. Please check that they are accurate.You can suppress this message by setting them explicitly. Run thefollowing command and follow the instructions in your editor to edityour configuration file:    git config --global --editAfter 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.gitCounting 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: tempremote: Please read the documentation and contact an administratorremote: if you feel the configuration is incorrectremote: 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/masterCounting 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 580bc0ebae7f7e752b25e9c7ba0b405c37897d61remote: ERROR:  committer email address kylin@localhost.localdomainremote: 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/contactremote: 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 580bc0ebae7f7e752b25e9c7ba0b405c37897d61remote: ERROR:  committer email address kylin@localhost.localdomainremote: ERROR:  does not match your user account.remote: ERROR:remote: ERROR:  The following addresses are currently registered:remote: ERROR:    84567012@qq.comremote: ERROR:remote: ERROR:  To register an email address, please visit:remote: ERROR:  http://172.16.6.220:9080/#/settings/contactremote: 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 logcommit 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 footerremote: 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 --amendremote: 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 worldremote: To ssh://172.16.6.220:29418/test.git * [new branch]      master -> refs/for/master
原创粉丝点击