简体   繁体   English

git 在多次修补程序和功能提交后同步分支

[英]git syncing up branches after a multiple of hotfixes and a feature commit

Hi: I have 2 branches master and dev which were in sync about 2 weeks ago.嗨:我有 2 个分支 master 和 dev,它们在大约 2 周前同步。 Would like some help on how to move a feature (commit F) to master branch now.想要一些关于如何将功能(提交 F)移动到主分支的帮助。 Have been reading up a number of git workflow models, just need to make sure I have understood it right before I commit and push the changes.已经阅读了许多 git 工作流模型,只需要确保在我提交和推送更改之前我已经理解了它。

2 weeks ago master 2 周前大师

...-C-D-E

acpt acpt

...-C-D-E

I added two hotfixes (H1 and H2) on two different dates, while working on another feature (commit: F) at the same time.我在两个不同的日期添加了两个修补程序(H1 和 H2),同时处理另一个功能(提交:F)。 So the branches look like this master所以树枝看起来像这个主人

           H2
          /
         H1
        /
...-C-D-E

dev开发

         H1 H2
        /  /
...-C-D-E-F

My questions are the following我的问题如下
1. Now I want to move F to master. 1.现在我想把F移到master上。 I was going to do git merge dev while in the master branch.我打算在 master 分支中执行git merge dev Is there anything wrong with this这有什么问题吗
2. Or should I be doing git merge <commit-id for F> while in the master branch. 2. 或者我应该在主分支中执行git merge <commit-id for F>
3. Or should I be developing F in a new branch and merging that branch into master and dev 3. 或者我应该在一个新分支中开发 F 并将该分支合并到 master 和 dev 中

As far as I understood from your development workflow, you are working with gitflow workflow.据我从您的开发工作流程中了解到,您正在使用 gitflow 工作流程。 In this workflow the main branches are:在此工作流中,主要分支是:

  • master - the most stable main branch master - 最稳定的主分支
  • development - development branch to develop and merge features in there (initially created from master) development - 开发分支以在其中开发和合并功能(最初从 master 创建)
  • feature branches - each time you want to develop a new feature, you have to create a new feature branch from latest development功能分支 - 每次你想开发一个新功能时,你必须从最新的开发中创建一个新的功能分支
  • hotfix - for hotfixes on master (if release is broken) hotfix - 用于 master 上的修补程序(如果版本被破坏)
  • release - created from development to push (release) changes to master发布 - 从开发创建以将更改推送(发布)到 master

If you were working on development instead of feature branches, then you have to merge development to master first and then follow the workflow.如果你在做开发而不是功能分支,那么你必须先合并开发以掌握,然后按照工作流程。 To answer your question: better to use first option:回答您的问题:最好使用第一个选项:

git checkout master
git merge dev //to merge dev into master

And then push to remote master.然后推送到远程主。

To make github happy (if you use github), you have to merge master back to development (so it would not diverge and will not complain).为了让 github 开心(如果你使用 github),你必须将 master 合并回开发(这样它不会发散也不会抱怨)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM