$git push origin obsolescenceL
#这样当然是不成功的啦蛤蛤,没有push权限的
$git push origin HEAD:refs/heads/obsolescenceL
#这样,其实也是不对的蛤蛤蛤
#以上两个,大概会出来类似以下的报错
remote: Resolving deltas: 100% (3/3)
remote: Branch refs/heads/obsolescenceL:
remote: You are not allowed to perform this operation.
remote: To push into this reference you need 'Push' rights.
remote: User: obsolescenceL
remote: Please read the documentation and contact an administrator
remote: if you feel the configuration is incorrect
remote: Processing changes: refs: 1, done
To https://xxx
! [remote rejected] HEAD -> obsolescenceL (prohibited by Gerrit)
error: 无法推送一些引用到 'https://xxx'
$git push origin HEAD:refs/for/obsolescenceL
#这个像样一点了
#gerrit相对于git提供了一个特有的命名空间"refs/for/"用来定义我们的提交上传到哪个branch,且可以用来区分我们的commit是提交到gerrit进行审核还是直接提交到git仓库
#但还是报错的
remote: Resolving deltas: 100% (3/3)
remote: Processing changes: refs: 1, done
remote: ERROR: [dc09195] 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); curl -o ${gitdir}/hooks/commit-msg https://web.toutiao.com/lib/infosys/download/software/commit-msg; chmod a+x ${gitdir}/hooks/commit-msg
remote: And then amend the commit:
remote: git commit --amend
remote:
To https://xxx
! [remote rejected] HEAD -> refs/for/obsolescenceL ([dc09195] missing Change-Id in commit message footer)
error: 无法推送一些引用到 'https://xxx'
#ok有hint了,照着hint做
$git rev-parse --git-dir
xxx
$curl -o xxx/hooks/commit-msg https://web.toutiao.com/lib/infosys/download/software/commit-msg; chmod a+x ${gitdir}/hooks/commit-msg
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4360 100 4360 0 0 7324 0 --:--:-- --:--:-- --:--:-- 7315
$git push origin HEAD:refs/for/obsolescenceL
#这回就成功啦
remote: Resolving deltas: 100% (3/3)
remote: Processing changes: new: 1, refs: 1, done
remote:
remote: New Changes:
remote: https://xxx/gerrit/161 feat: complete the 1st, 2nd and 3rd problem
remote:
To https://xxx
* [new branch] HEAD -> refs/for/obsolescenceL