Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git merge pending due to an abandoned commit

Tags:

git

gerrit

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.

  1. git commit in local for A.

  2. git push for A in remote.

  3. A got abandoned, but my local git has commit A.

  4. git commit in local for B in same branch (Makes B dependent on A).

  5. git push B in remote in same branch.

  6. 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?

like image 808
VinayChoudhary99 Avatar asked Dec 20 '22 01:12

VinayChoudhary99


2 Answers

There are several ways to fix your problem. Pick whichever you feel most comfortable with.

Here is one:

  1. git checkout yourbranch (make sure you are on the right branch)
  2. git reset --hard A^ (reset everything to the commit before A)
  3. git cherry-pick B (where B is the hash of the commit you want to keep)
  4. git log (confirm that it is what you wanted)
  5. git push --force (may need to specify other options depending on how you usually push)

Here is another, result is equivalent:

  1. git checkout yourbranch (make sure you are on the right branch)
  2. git rebase --onto A^ A (rebase everything after A on top of the commit before A, effectively removing A)
  3. git log (confirm that it is what you wanted)
  4. git push --force (may need to specify other options depending on how you usually push)

Here is a third, result still equivalent:

  1. git checkout yourbranch (make sure you are on the right branch)
  2. git rebase --interactive A^ (will open up your editor)
  3. Delete the line showing commit A, save and close
  4. git log (confirm that it is what you wanted)
  5. git push --force (may need to specify other options depending on how you usually push)
like image 167
jsageryd Avatar answered Dec 31 '22 07:12

jsageryd


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.

like image 44
Moises Gonzaga Avatar answered Dec 31 '22 06:12

Moises Gonzaga