I have two commits. Commit B depends on commit A. Commit A was abandoned. Now I am getting error for merging B. It says submitted, merge pending due to dependency of B on A.
I have googled around but cant find an exact answer. I need step by step solution as I am a novice in git and am finding hard to understand how to resolve this.
This is what happened.
git commit in local for A.
git push for A in remote.
A got abandoned, but my local git has commit A.
git commit in local for B in same branch (Makes B dependent on A).
git push B in remote in same branch.
Now B is not merging since A is abandoned.
I need to merge B and I want dependency on A removed. Hope its clear now!
Here is Server error:
Change 1184 - Submitted, Merge Pending
In comments:
Gerrit Code Review
Change could not be merged because of a missing dependency. The following changes must also be submitted: (commit-id, which was abandoned)
Will rebase work? If so, how to do it?
There are several ways to fix your problem. Pick whichever you feel most comfortable with.
Here is one:
git checkout yourbranch
(make sure you are on the right branch)git reset --hard A^
(reset everything to the commit before A)git cherry-pick B
(where B is the hash of the commit you want to keep)git log
(confirm that it is what you wanted)git push --force
(may need to specify other options depending on how you usually push)Here is another, result is equivalent:
git checkout yourbranch
(make sure you are on the right branch)git rebase --onto A^ A
(rebase everything after A on top of the commit before A, effectively removing A)git log
(confirm that it is what you wanted)git push --force
(may need to specify other options depending on how you usually push)Here is a third, result still equivalent:
git checkout yourbranch
(make sure you are on the right branch)git rebase --interactive A^
(will open up your editor)git log
(confirm that it is what you wanted)git push --force
(may need to specify other options depending on how you usually push)Here is an issue like yours.
If committ B has a dependency on A, then B cannot be merged until A is merged. Since you have abandoned A, Gerrit will not automatically merge B.
What you will need to do is modify B (perhaps using
git rebase
) so that it no longer depends on A, and resubmit the change to Gerrit.
how do I rebase / merge it?
git-review -d 1184
git rebase origin/master
git status
<edit "both modified" files in status report>
git add <files>
git rebase --continue
git review
Find more useful information here about this kind of issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With