Missing dependency in Gerrit

冷暖自知 提交于 2019-12-30 07:15:54

问题


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 depending on anything, Gerrit managed to auto-merge it. Now, the fourth (depending on abandoned third) is a real problem.

Gerrit states Submitted, Merge Pending with:

Change could not be merged because of a missing dependency.
The following changes must also be submitted:

and giving me change-Id of both abandoned changes. How can I get rid of this chaos?

From what I've already learnt by googling and SO-ing (especially this and this one -- doesn't help much), the entire problem arose, because I haven't been using branches, only working directly on master.

Fine, I'll promise to be better next time, but how to fix current problem? I've tried to apply many solutions, found in the Internet or here, on SO, but none of them helps. Each git pull and git push claims, that both my local and remote are up-to-date, but I see no way to get rid of dependent change.


回答1:


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.



回答2:


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




回答3:


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.



来源:https://stackoverflow.com/questions/20496959/missing-dependency-in-gerrit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!