2017-08-07 395 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