Git merge expected due to rejection of commit

I have two commits. Commit B depends on commit A. Commit A was left. Now I get an error for merge B. This says that it is sent, the merge is expected due to the dependence of B on A.

I googled around, but cannot find the exact answer. I need a step-by-step solution since I am new to git and it is hard for me to figure out how to resolve this.

Here is what happened.

  • git commit in local for A.

  • git press for A on the remote control.

  • Refused, but my local git has a commit A.

  • git commit in local for B in the same branch (makes B dependent on A).

  • git press B on the remote in the same branch.

  • Now B does not merge, since A is abandoned.

I need to merge B, and I want the dependency on A to be removed. Hope this is clear now!

Here is the server error:

Edit 1184 - Sent, Awaiting Merge

In comments:

Gerrit Code Overview

Change cannot be merged due to missing dependency. the following changes should also be submitted: (commit-id that was left)

Will the reboot work? If so, how to do it?

+4
source share
2 answers

There are several ways to fix your problem. Choose what you like best.

Here is one of them:

  • git checkout yourbranch (make sure you are on the right branch)
  • git reset --hard A^ (reset everything to commit to A)
  • git cherry-pick B (where B is the commit hash you want to keep)
  • git log (make sure this is what you wanted)
  • git push --force (may need to specify other options depending on how you usually click)

Here is another result:

  • git checkout yourbranch (make sure you are on the right branch)
  • git rebase --onto A^ A (rebase everything after A over commit to A, effectively removing A)
  • git log (make sure this is what you wanted)
  • git push --force (may need to specify other options depending on how you usually click)

Here is the third, the result is still equivalent:

  • git checkout yourbranch (make sure you are on the right branch)
  • git rebase --interactive A^ (your editor will open)
  • Delete row showing commit A, save and close
  • git log (make sure this is what you wanted)
  • git push --force (may need to specify other options depending on how you usually click)
+5
source

Here is a problem similar to yours.

If committ B has a dependency on A, then B cannot be merged until A is merged. Since you left A, Gerrit will not automatically merge B.

What you need to do is change B (possibly using git rebase ), so that it no longer depends on A and resubmit the change to Gerrit.

How do I reinstall / 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 issue.

0
source

Source: https://habr.com/ru/post/947036/


All Articles