Gerrit将相同的变更集推送给master和分支 [英] Gerrit push the same changesets to both master and a branch

查看:944
本文介绍了Gerrit将相同的变更集推送给master和分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Gerrit的一个功能分支上工作时,我想将我的功能分支变更推送到 master (以便其他人可以使用它)以及我的功能分支(所以我可以继续工作,而不需要对主人进行更改),但是一旦我推到一个分支,我就不能把gerrit推到另一个分支上去。



例如,如果I git push HEAD:refs / for / master ,那么随后的 git push HEAD:refs / for / feature 将会导致:

pre $ $ $ $ c $合计0(增量0),重用0(增量0)
远程:处理更改:refs:1,完成
到ssh://gerrit.server/repo.git
! [远程拒绝] HEAD - > refs / for /功能(没有新的变化)
错误:未能将一些文件推送到'ssh://gerrit.server/repo.git'

当然有新的改变,但只针对不同的分支。



目前,我有两个选择:


  1. 推送到功能分支,让它进行测试,审查&提交,然后手动将其合并到主,并得到测试,审查&提交。


    • 这里的问题是,如果其他更改合并到主拉伸主之间进行合并并提交了合并提交,那么我们会得到一个额外的不必要的合并。


  2. 推送给master,让它测试,审查&提交,然后让我们的gerrit专家将gerrit中的特性分支ref更新到需要的地方。


    • 除了作为黑客,可能会出现严重的错误,这并不是您想要求某人经常执行的操作。

    • CI服务器仅在 master ,不在分支上。




  3. 理想情况下,我想只推送到功能分支,然后推送到 master ,并拥有gerrit意识到第二个推动是将提交(或提交)合并为主;或者可选地,推送到主服务器然后推送到特性分支,并让gerrit意识到这只是一个请求来快速转发特性分支引用。不幸的是,我还没有找到任何方法来做到这一点。



    是否有一种干净的方式将更改或一组更改推送到它们的功能分支和主控?注意,我们有基于合并的工作流程,而不是基于基于工作流程的工作流程,所以依赖基础工作流程的回答将不会对我们有用。



    发现选择合并基础我认为 base 选项可能是我正在寻找的,但是当我尝试 git push源头HEAD:refs / for / master 后跟 git push origin HEAD:refs / for / feature%base = $(git rev-parse origin / feature)推到功能分支失败的方式与我刚刚完成的方式相同 git push origin HEAD:refs / for / feature 即它说<$ c由于(无新变化)


    $ c> [远程拒绝]

    我们也有尝试在Gerrit项目配置中启用 create-new-change-for-all-in-target-in-target 选项,但它以完全相同的方式失败:

      $ git commit -am功能和主控的新提交。 
    [fix 1234567]新提交
    更改了19个文件,19个插入(+),19个删除( - )

    $ git push origin HEAD:refs / for / master
    计数对象:48,完成。
    使用多达12个线程的增量压缩。
    压缩对象:100%(25/25),完成。
    写作对象:100%(25/25),2.20 KiB,完成。
    总计25(增量24),重用0(增量0)
    远程:解决变化:100%(24/24)
    远程:处理更改:新:1,参考:完成
    remote:
    remote:新增更改:
    remote:http://gerrit.server/1234功能和主控制器的新提交。
    remote:
    至ssh://gerrit.server/repo.git
    * [新分支] HEAD - > refs / for / master

    $ git push origin HEAD:refs / for / feature
    总计0(delta 0),重用0(delta 0)
    remote:处理更改:参考:1,完成
    到ssh://gerrit.server/repo.git
    ! [远程拒绝] HEAD - > refs / for / feature(没有新的变化)
    错误:未能将一些refs推送到'ssh://gerrit.server/repo.git'

    我也试着先推送到功能分支,然后是mastedr,但是正如预期的那样,这导致了相同的拒绝。

    解决方案

    请参阅我的回答具有追踪功能分支的Gritrit :启用创建新变更所有目标选项在Gerrit> = 2.11至考虑目标分支,当确定新的更改打开也应该有助于您的情况。


    Working on a feature branch in Gerrit, I want to push my feature branch changes to master (so others can make use of it) as well as to my feature branch (so I can keep working on it without the changes on master), but once I've pushed to one, I can't gerrit push to the other.

    For example, if I git push HEAD:refs/for/master then a subsequent git push HEAD:refs/for/feature will result in:

    Total 0 (delta 0), reused 0 (delta 0)
    remote: Processing changes: refs: 1, done    
    To ssh://gerrit.server/repo.git
     ! [remote rejected] HEAD -> refs/for/feature (no new changes)
    error: failed to push some refs to 'ssh://gerrit.server/repo.git'
    

    Of course there are new changes, but only with respect to a different branch.

    At the moment, I have two options:

    1. Push to the feature branch, get it tested, reviewed & submitted, then manually merge it into master and get that tested, reviewed & submitted.

      • The problem here is that if other changes are merged into master between my pulling master to do the merge and my merge commit being submitted, then we end up with an extra unnecessary merge.
    2. Push to master, get it tested, reviewed & submitted, then get our gerrit guru to update the feature branch ref in gerrit to the where it needs to be.

      • Apart from being a hack, with the potential to go badly wrong, it isn't something you would want to have to ask someone to do very often.
      • The CI server only runs tests on master, not on the branch.

    Neither of these solutions is very satisfactory.

    Ideally I would like to just push to the feature branch, and then push to master and have gerrit realise that the second push was to get the commit (or commits) merged to master; or alternatively, push to master then push to the feature branch, and have gerrit realise that this is just a request to fast-forward the feature branch ref. Unfortunately I haven't found any way to do this.

    Is there a clean way to push a change, or set of changes, to both their feature branch and master?


    Note, we have merge based workflow rather than a rebase based workflow, so answers which rely on a rebase workflow will not be useful to us.

    Having discovered Selecting Merge Base I thought the base option might be what I was looking for, however when I try git push origin HEAD:refs/for/master followed by git push origin HEAD:refs/for/feature%base=$(git rev-parse origin/feature) the push to the feature branch fails in the same way as if I'd just done git push origin HEAD:refs/for/feature i.e. it says [remote rejected] due to (no new changes).


    We have also tried enabling the create-new-change-for-all-not-in-target option in the Gerrit project configuration, but it fails in exactly the same way:

    $git commit -am "New commit for feature and master."
    [fix 1234567] New Commit
     19 files changed, 19 insertions(+), 19 deletions(-)
    
    $git push origin HEAD:refs/for/master
    Counting objects: 48, done.
    Delta compression using up to 12 threads.
    Compressing objects: 100% (25/25), done.
    Writing objects: 100% (25/25), 2.20 KiB, done.
    Total 25 (delta 24), reused 0 (delta 0)
    remote: Resolving deltas: 100% (24/24)
    remote: Processing changes: new: 1, refs: 1, done    
    remote: 
    remote: New Changes:
    remote:   http://gerrit.server/1234 New commit for feature and master.
    remote: 
    To ssh://gerrit.server/repo.git
     * [new branch]      HEAD -> refs/for/master
    
    $git push origin HEAD:refs/for/feature
    Total 0 (delta 0), reused 0 (delta 0)
    remote: Processing changes: refs: 1, done    
    To ssh://gerrit.server/repo.git
     ! [remote rejected] HEAD -> refs/for/feature (no new changes)
    error: failed to push some refs to 'ssh://gerrit.server/repo.git'
    

    I also tried pushing to the feature branch first and then mastedr, but as expected, this results in the same rejection.

    解决方案

    See my answer to Gerrit with tracked feature branches: Enabling the create-new-change-for-all-not-in-target option in Gerrit >= 2.11 to take into account target branch when determining new changes to open should also help in your case.

    这篇关于Gerrit将相同的变更集推送给master和分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆