【问题标题】:How to remove feature branch from develop in Git/Bitbucket如何在 Git/Bitbucket 中从开发中删除功能分支
【发布时间】:2016-08-04 10:38:39
【问题描述】:

也许我对 Git-Flow 的处理方法有误...

我将 Bitbucket (git) 与 GitFlow 工作流结合使用。

我想知道是否可以在与开发分支合并后完全删除功能分支的源更改即使在合并其他分支功能之后

编辑:我试图解释得更好。我不想删除一个特性分支,我想删除特性分支带来的所有变化。

如果我的功能分支是最后一次操作,我认为我可以恢复。 但如果: - 我已经在开发分支上完成了我的功能分支的合并 - 其他功能已合并到开发分支上

只有在此操作之后,我才需要在不丢失任何其他功能的情况下删除我的第一个功能,这可能吗?

谢谢,鲁杰罗

【问题讨论】:

标签: git bitbucket atlassian-sourcetree sourcetree


【解决方案1】:

在解释您的问题时,您希望撤消将 featurebranch 合并到 develop 中。

这应该可以使用

git checkout develop
git revert mergecommit -m 1

其中mergecommit 是实际合并提交的哈希值(如git log 所示)。

git help revert 中有一个警告:

   -m parent-number, --mainline parent-number
       Usually you cannot revert a merge because you do not know which side of the merge should be considered the
       mainline. This option specifies the parent number (starting from 1) of the mainline and allows revert to reverse
       the change relative to the specified parent.

       Reverting a merge commit declares that you will never want the tree changes brought in by the merge. As a
       result, later merges will only bring in tree changes introduced by commits that are not ancestors of the
       previously reverted merge. This may or may not be what you want.

所以:

  • 您需要确定要选择合并的哪一侧。 git log,查找Merge: aaaaa bbbbb 行,并相应地选择-m 1-m 2
  • 您可能需要提供-n 选项来避免自动提交,以免在出错时产生一些麻烦。

【讨论】:

  • 谢谢!我编辑了我的问题......即使其他功能在我之后合并,也可以删除?谢谢
  • 是的,有可能。它不会编辑历史记录,但您将创建一个实际上撤消更改的新提交。当然,如果你运气不好,你可能会也可能不会有很多冲突。
  • 特性分支提交后,如果特性需要修复怎么办?
  • @TomAnderson,我会说git cherry-pick'ing 相关的后续提交可能值得一试。
猜你喜欢
  • 2015-11-18
  • 2020-09-14
  • 2023-02-09
  • 2012-01-17
  • 2013-07-25
  • 2020-11-02
  • 2013-02-15
  • 2023-02-13
  • 2023-03-26
相关资源
最近更新 更多