将分支合并两次

发布于 2025-01-18 23:52:41 字数 424 浏览 3 评论 0原文

我想将分支合并两次到另一个分支。 假设我在主分支中有一个文件。

src/file.txt的内容

abc

  1. 我已经创建了Master的“ FIX”分支,并将src/file.txt更新为abc -fix
  2. 我已合并了'fix fix fix “分支通过合并PR(修复 - > Master)
  3. 现在我创建了Master的“功能”分支,并将SRC/File.txt更新为 abc-功能
  4. 功能 - > master)将“功能”分支合并为主人

我已经通过合并pr ( 分支。当我创建PR修复时 - > github大师显示没有什么可比较的。

我该如何实现?

I want to merge a branch twice to another branch.
Let's say, I had a file in master branch.

Contents of src/File.txt

ABC

  1. I've created 'fix' branch from master and updated the src/File.txt to ABC - Fix
  2. I've merged 'fix' branch to master by merging the PR (fix -> master)
  3. Now I've created 'feature' branch from master and updated the src/File.txt to
    ABC - Feature
  4. I've merged 'feature' branch to master by merging the PR (feature -> master)

Now, I want to have ABC - Fix on my master branch. When I'm creating the PR fix -> master, Github is showing There isn’t anything to compare.

How can I achieve this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌路黄昏 2025-01-25 23:52:41
  1. 根据您的问题,在步骤2中,您合并了(修复 - 主人),因此您的Fix分支的所有这些提交都将移至您的主分支。因此,稍后,当您试图从ABC - 修复分支中提出另一个PR时,Git显示了“没有什么可比较”,因为所有提交已经存在。
  2. 但是,如果您必须再次提高PR,那么您需要在ABC -FIX分支中至少有一个新提交。如果您目前没有任何更改的代码可以更改,则应尝试使用此git命令 -
 git commit --allow-empty -m <message>

这将在您的ABC中创建一个新的提交 - 修复分支(无需更改代码中的任何内容),您可以将PR提高到Master成功地。

  1. As per your question, in step 2 you have merged (fix -> master) so all those commits from your fix branch would be moved to your master branch. Thus, later when you are trying to raise another PR from your ABC - Fix branch, git shows "There isn’t anything to compare" as all the commits are present already.
  2. However, if you must raise a PR again, then you need to have atleast one new commit in your ABC - Fix branch. If you don't have anything to change in the code at this point, you should try using this git command -
 git commit --allow-empty -m <message>

This will create a new commit in your ABC - Fix branch(without changing anything in code) for you to raise PR towards master successfully.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文