2017-08-07 396 views
0

我试图提交一个额外的(无关的)提交之后提交一个前一个提交给Gerrit。我在两个独立的分支上创建了前一个和当前的提交。这里是工作流程的一个例子:如何在向Gerrit提交上次提交后提交额外的提交?

  1. git checkout -b <branch-1>
  2. git add folder1/*
  3. git commit -m "Added folder1."
  4. git review

它被提交到格里特它输出的信息,包括链接到审查。然后,我去另一个(再次,不相关的)改变工作:

  • git checkout -b <branch-2>
  • git add folder2/*
  • git commit -m "Added folder2."
  • git review
  • 正是在这一点,我遇到以下几点:

    You are about to submit multiple commits. This is expected if you are 
    submitting a commit that is dependent on one or more in-review 
    commits. Otherwise you should consider squashing your changes into one 
    commit before submitting. 
    
    The outstanding commits are: 
    373ea8b (HEAD -> branch-2) Added folder2. 
    e626f4c (branch-1) Added folder1. 
    
    Do you really want to submit the above commits? 
    Type 'yes' to confirm, other to cancel: n 
    Aborting. 
    

    如何避免此冲突?

    +0

    “提交”,你的意思是“推”? Gerrit的“提交”是在审查后将提交合并到目标分支中。您可以在更改页面上看到“提交”按钮。如果第一个还没有提交,如果第二个依赖于第一个,则第二个不能提交。所以它会在'git review'时发出警告。你可以回答“是”,或者git-检查第一个,提交它,然后git-检查第二个。 – ElpieKay

    回答

    0

    的问题是,你是第二次提交的基础上,第一个:

    A    <= origin/branch 
    \ 
        \-- B  <= branch-1 
         \ 
         \-- C <= branch-2 
    

    要在不相关的分支工作,你应该工作“并联”具有自主提交这样的:

    /-- B <= branch-1 
    /
    A  <= origin/branch 
    \ 
        \-- C <= branch-2 
    

    第一次提交:

    git checkout -b <branch-1> origin/<branch> 
    git add folder1/* 
    git commit -m "Added folder1." 
    git review 
    

    第二承诺:

    git checkout -b <branch-2> origin/<branch> 
    git add folder2/* 
    git commit -m "Added folder2." 
    git review