由于被放弃的提交,Git合并等待 [英] Git merge pending due to an abandoned commit

查看:764
本文介绍了由于被放弃的提交,Git合并等待的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个提交。提交B取决于提交A.提交A被放弃。现在我得到合并B的错误。它表示提交,由于B依赖于A,合并等待。



我搜索了一下,但无法找到确切的答案。我需要一步一步的解决方案,因为我是git的新手,并且很难理解如何解决这个问题。



这就是发生了什么。


  1. git在本地提交A。


  2. A被遗弃了,但是我的本地git已经提交了A。

  3. git 在本地为同一分支中的B提交(使B依赖于A)。 >
  4. 现在B并没有合并,因为A被放弃了。


合并B和我想要依赖于A删除。现在希望它清楚!



这是服务器错误:


更改1184 - 已提交,合并待定


在评论中:


Gerrit Code Review

由于缺少依赖关系,无法合并更改。
下面的变化也必须提交:
(commit-id,这已被放弃)


工作?如果是这样,怎么做?

解决方案

有几种方法可以解决您的问题。挑选你感觉最舒服的一个。



以下是一个:


  1. git checkout yourbranch (确保您位于右分支)

  2. git reset --hard A ^ (在A之前重置所有内容)

  3. git log (确认它是你想要的)
  4. git push --force (可能需要根据您通常推送的方式指定其他选项)

下面是另外一个,结果相同:


  1. git checkout yourbranch code>(确保你在正确的分支)

  2. git rebase --onto A ^ A 在A之前的提交之后,有效地删除A)
  3. git log (确认它是你想要的)

  4. git push --force (可能需要指定其他选项取决于您通常推送的方式)

以下是第三个结果,仍等同:


  1. git checkout yourbranch (确保您位于右侧分支)

  2. git rebase --interactive A ^ (将打开您的编辑器)
  3. 删除显示提交A的行,保存并关闭
  4. li>
  5. git log (确认它是你想要的)

  6. git push --force (可能需要根据您通常推送的方式指定其他选项)


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?

解决方案

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)

这篇关于由于被放弃的提交,Git合并等待的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆