7

I searched a lot but was not able to find a confident solution(pardon me as I am new to git and maybe I didn't get some term well). So I will state my exact problem here:

  1. I have a software (say in branch main) of which I just released v5.0 and then I created a new branch (say 5b) to fix all the issues that come in the branch.

  2. All the new features are being added to main branch.

  3. Now I have to supply a build with the new features to someone, but I also want to have all the bugfixes.

  4. My logic says that I can pull all the changes from 5b, merge it with main and make a build.

The only problem is that I want to keep that branch 5b as it is so that other fixes can be added to it. While in the main, all the changes from 5b should be available.

Please let me know how to accomplish this. A step wise answer with a bit of detail will be really helpful.

Thanks,

4

1 回答 1

11

你有一个分支 - 主要

您有一个带有错误修复的分支 - 5b

现在,为了将您的错误修复更改合并到 main,

从主分支中提取最新更改:

 git checkout main
 git pull origin main

将主分支中的更改合并到 5b 分支(5b 分支与主分支是最新的):

 git checkout 5b
 git pull origin 5b
 git merge main
 git push origin 5b

将您的 5b 分支更改合并回 main:

 git checkout main
 git merge 5b
 git push origin main

这不会删除您的 5b(bug_fixes) 分支或主分支。您可以通过这种方式继续将您的错误修复分支更改合并到 main 中。

于 2013-06-03T11:55:17.343 回答