简体   繁体   English

我可以在GitHub上应用Git-Flow工作流程吗

[英]Can I apply the Git-Flow workflow on GitHub

I want to achieve the same workflow as outlined here in git-flow but using GitHub. 我想实现与git-flow中概述的工作流相同的工作流,但要使用GitHub。 However the problem seems to be that when merging with GitHub (either merge, squash or rebase) a new commit hash is added to master. 但是问题似乎是,当与GitHub合并时(合并,压缩或变基),新的提交哈希会添加到master中。 This causes the permanent "develop" branch to start thinking its 1 commit behind master. 这导致永久的“ develop”分支开始考虑其在master后面的1个提交。

Is there some way of replicating this workflow on github? 有什么方法可以在github上复制此工作流程吗? Or should i give up and use the more simple github-flow 还是我应该放弃并使用更简单的github-flow

Short answer : Don't merge to master using Pull Requests; 简短的回答 :不要使用Pull Requests合并到master。 instead perform the merge locally using "fast-forward", then push the branch: 而是使用“快进”在本地执行合并,然后推送分支:

git checkout master
git merge --ff-only develop
git push

Caveat : This only works if develop has every commit that master has. 警告 :这仅适用develop具有每一个承诺是master了。

Long Answer: Merges on GitHub typically occur by approving a pull request ; 长答案:GitHub上的合并通常是通过批准请求请求来完成的 somebody makes a new feature branch, opens a pull request through the website, and later the merge takes place when the pull request is approved. 有人创建了一个新的功能分支,通过网站打开了一个拉取请求,然后在拉取请求被批准后进行合并。 The approval creates a merge-commit on the new branch. 批准将在新分支上创建合并提交。 You want to avoid the merge-commit. 您要避免合并提交。 But as far as I know, this is Github's default behavior, which can't be overridden. 但是据我所知,这是Github的默认行为,不能被覆盖。 The only way to get around this would be to perform the merge using the "fast-forward" strategy locally with your tool of choice, then push the changes to the GitHub repo. 解决此问题的唯一方法是使用您选择的工具在本地使用“快进”策略执行合并,然后将更改推送到GitHub存储库。

You can only fast-forward if the branch you are merging is a direct descendant of the master branch. 如果要合并的分支是master分支的直接后代,则只能快进。 If master has any commits that develop does not have, you won't be able to fast-forward, and a merge-commit will be created. 如果master拥有develop中没有的任何提交,则您将无法快速前进,并且将创建合并提交。 If you're using git-flow's technique for branching "hotfix" branches from master , you may run into this issue. 如果您使用git-flow的技术从master分支“ hotfix”分支,则可能会遇到此问题。

Is there a benefit to doing this? 这样做有好处吗? Depends. 要看。 You end up with a more "streamlined" repository with less commits, but you might miss out on the benefits that Pull Requests provide -- better visibility of changes to code (though in practice, code review usually happens when merging feature branches. Pull Requests merging from develop to master can feel redundant). 您最终将获得一个更“简化”的存储库,提交次数更少,但是您可能会错过Pull Requests提供的好处-更好地查看代码更改(尽管在实践中,通常在合并功能分支时进行代码检查。Pull Requests从developmaster可以感到多余)。

I suggest you to give up and start use your "platflorm" flow. 我建议您放弃并开始使用“ platflorm”流程。 I mean that github (as gitlab, beanstalk or bitbucket) propote its own flow. 我的意思是github(如gitlab,beanstalk或bitbucket)支持它自己的流程。 I suggest you to start to use master as develop branch (for next release) and keep all old stable releases in another branch. 我建议您开始将master用作development分支(用于下一发行版),并将所有旧的稳定发行版保留在另一个分支中。 For example: 例如:

  • branch master (5.4 development) 分支主管(5.4开发)

  • branch 5.3 (the current release) 分支5.3(当前版本)

    • ... 5.3.2 ... 5.3.2
    • ... 5.3.1 ... 5.3.1
    • here you can tag 5.3.0 在这里您可以标记5.3.0
  • branch 4.9 (an LTS version of old release) 分支4.9(旧发行版的LTS版本)

    • ... 4.9.2 ... 4.9.2
    • ... 4.9.1 ... 4.9.1
    • here you can tag 4.9.0 在这里您可以标记4.9.0

Always fix in release branches and add new feature in master. 始终修复发行分支,并在master中添加新功能。 If master keep retro compatibility just prepare next minor. 如果主人保持复古的兼容性,那就准备下一个未成年人。 If master broken something, ... increment the major release. 如果master破坏了某些内容,则...增加主要版本。

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

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