Missing dependency in Gerrit

后端 未结 3 1141
野趣味
野趣味 2021-01-06 16:34

I had four changes in Gerrit, each depending on previous one (except first, of course). I\'ve abandoned second and third and reviewed first and fourth. Since first wasn\'t d

相关标签:
3条回答
  • 2021-01-06 16:58

    I used the answer from Magnus and did the interactive rebase and removed my previous commit but still had some merge conflicts. Then I manually updated the files to resolve the conflicts.

    Finally added the modified files, then ran "git rebase --continue" to resolve the issue.

    0 讨论(0)
  • 2021-01-06 17:10

    You need to remove the two unwanted commits corresponding to the abandoned changes from the ancestry of commit 4, i.e. the desired state is for git log to only list commits 4 and 1. When that's done, pushing a new patch set should remove the stated dependency. Getting rid of commits 2 and 3 can be done in many ways, including

    • doing an interactive rebase (git rebase -i HEAD~4 and deleting the lines for the two commits you don't want), or
    • starting a new branch based on the tip of the upstream branch and cherry-picking commit 4.
    0 讨论(0)
  • 2021-01-06 17:13

    Ok, here is my revised answer

    Starting point is where you have your 4 commits in a row:

    #git log --graph --decorate --oneline
    * 448fd95 (HEAD, master) Change 4
    * 3950f5f Change 3
    * 8753adf Change 2
    * cdcfe20 Change 1
    

    Next, create a temp branch from the head

    #git branch temp
    #git log --graph --decorate --onelin
    * 448fd95 (HEAD, temp, master) Change 4
    * 3950f5f Change 3
    * 8753adf Change 2
    * cdcfe20 Change 1
    

    Now you need to reset your master to get rid of the unwanted history:

    #git reset --hard cdcfe20
    HEAD is now at cdcfe20 Change 1
    #git log --graph --decorate --oneline
    * cdcfe20 (HEAD, master) Change 1
    

    Cherry pick your change 4 into the master

    #git cherry-pick 448fd95
    [master 19c5ba1] Change 4
     1 file changed, 1 insertion(+), 1 deletion(-)
    #git log --graph --decorate --oneline
    * 19c5ba1 (HEAD, master) Change 4
    * cdcfe20 Change 1
    

    Now you can push the last change to gerrit and your dependencies are fixed

    0 讨论(0)
提交回复
热议问题