简体   繁体   English

使用Git Flow时如何保持分支同步

[英]How to keep branches in sync when using Git Flow

This is the workflow we currently follow: 这是我们当前遵循的工作流程:

  1. Finish a feature and merge it into develop branch 完成功能并将其合并到develop分支
  2. Create a release branch from develop 从develop创建release分支
  3. Run build scripts on release branch release分支上运行构建脚本
  4. Create a pull request to merge the release branch into master 创建请求请求以将release分支合并到master
  5. Accept the release branch pull request and merge 接受release分支拉取请求并合并
  6. The master branch can then deploy to live server by running deploy command 然后,可以通过运行deploy命令将master分支部署到活动服务器上

This all works great, except in my Git repo my branches are out of sync master is now behind develop because it doesn't have the merge commits that happened from the pull request merging the release branch into develop . 回购我的分支是不同步的这一切工作进展顺利,但在我的Git的master现在落后develop ,因为它没有从拉入请求合并发生的合并提交release支进develop But master is also ahead of develop as it now contains merge commits from the pull request to get the release branch into master 但是master也领先于develop因为它现在包含来自pull请求的合并提交,以将release分支引入master

I am able to click sync in Bit Bucket to get all the branches up to date, but this just feels like an odd process to go through and would be nicer to keep the branches in sync automatically. 我可以在“位存储桶”中单击“同步”以使所有分支保持最新状态,但这听起来像是一个奇怪的过程,并且最好使分支自动保持同步。

Or, does it not really matter that they are out of sync? 或者,它们不同步真的不重要吗?

Here is a link to Git Flow process in case you are unfamiliar with it: http://nvie.com/posts/a-successful-git-branching-model/ 如果您不熟悉它,这是Git Flow流程的链接: http : //nvie.com/posts/a-successful-git-branching-model/

Thanks. 谢谢。

When you merge the release branch to master you either merge develop also and push the updated develop branch or create a new one from the master. 当您将发行分支合并到母版时,您也可以合并开发并推送更新的开发分支,或者从母版创建一个新分支。 If you merge develop and push then everyone who has access to develop will get updated develop branch on next update. 如果您合并开发并推送,那么有权访问开发的每个人都将在下一次更新时获得更新的develop分支。

Your master and remotes master are out of sync as you have not taken update from the remote. 您的主服务器和远程主服务器不同步,因为您尚未从远程服务器获取更新。 This you have to do! 这是你必须做的! :) :)


Adding nwinkler's answer for better visibility as answer: 添加nwinkler的答案以获得更好的可见性作为答案:

You need to merge back into develop after doing the release. 发布后,您需要重新合并到开发中。 In our workflow, I merge the master branch back into develop after the release. 在我们的工作流程中,我将master分支合并到发行版之后的development中。 That way you get all of the changes from the release merge and you make sure that you can merge everything into master when you do the next release. 这样,您就可以从发行版合并中获得所有更改,并确保在进行下一个发行版时可以将所有内容合并到主版本中。 Looks like that last step is missing from your workflow 您的工作流程似乎缺少最后一步

If you got what you wanted then please accept it and close it! 如果您有想要的东西,请接受并关闭它!

Hope it helped! 希望能有所帮助!

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

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