[英]Git: Are MERGING master into feature branch and REBASING feature branch on master equivalent?
Does merging
master into a feature branch and rebasing
feature branch on master have same end result in every possible situation, or should I favor one or other in a specific context and why? 是否
merging
掌握到一个特性分支和rebasing
的主 功能分支具有相同的最终结果在所有可能的情况,还是应该倾向于在一个特定的背景下一个或其他,为什么? I know merging creates additional commit for better history comprehension, but I'm more interested in the actual outcome of an operation and it's probability to succeed. 我知道合并会产生更多的提交,以更好地理解历史,但是我对操作的实际结果以及成功的可能性更感兴趣。 So is there an actual difference, or could I choose either approach based on convention (or even use them both inclusive)?
因此,是否存在实际差异?或者我可以根据惯例选择哪种方法(甚至可以同时使用两者)?
Also, how often should I need to sync feature branch
with master
? 另外,我应该多久将
feature branch
与master
同步一次? Is it a good practice to merge/rebase
every time I return to develop a specific feature, or should I keep the feature isolated from the rest of the architecture for as long as possible? 每次返回以开发特定功能时都进行
merge/rebase
重新设置是一种好习惯,还是应该使该功能与架构的其余部分保持尽可能长的隔离?
How to scope with situation when multiple features are highly dependent of each other? 当多个功能彼此高度依赖时,如何适应情况? Should the features be developed as a single feature branch, or as a distinct feature branches merged to public feature branch?
应该将功能开发为单个功能分支,还是作为合并到公共功能分支的独特功能分支开发? Lets say, in
Spring framework
, many configurations and layers are dependent of each other. 可以说,在
Spring framework
,许多配置和层是相互依赖的。 What is the common workflow to keep it all whole and sync? 什么是使所有流程保持完整和同步的通用工作流程?
Both merging and rebasing solve the same problem in a very different way. 合并和重新定标都以非常不同的方式解决了相同的问题。 Unlike rebasing, merging is non-destructive.
与重新设置不同,合并是无损的。 However, as long as you follow the Golden Rule of Rebasing, everything will work fine, and you can enjoy having a neat commit history.
但是,只要您遵循“重新定购的黄金法则”,一切都会很好,并且您可以享受整洁的提交历史。 The rule is "don't use rebasing with public branches."
规则是“不要在公共分支机构使用基础调整”。
Also, how often should I need to sync feature branch with master?
另外,我应该多久将功能分支与master同步一次?
This is mostly a matter of taste. 这主要是一个品味问题。 As explained in Pro Git , there are different Branching Workflows that one can choose from.
如Pro Git中所述 ,可以选择不同的分支工作流程。
Rebasing and merging are not equal in all situations as when you rebase on master you are actually make new commits on top of master, which will have a different id and contents. 在所有情况下,重定基址和合并都不相等,因为当您基于master进行基础调整时,实际上是在master之上进行新的提交,这将具有不同的id和内容。 This is why it is important to not rebase public branches.
这就是为什么不重新设置公共分支机构的基础很重要的原因。 However, rebasing can give you a nice clean history.
但是,重新定基可以为您提供清晰的历史记录。
As for the branch section of the question: it appears that what you are looking for is a branching model. 至于问题的分支部分:看来您正在寻找的是分支模型。 One of the most popular branching model is git flow which uses a merge model.
最受欢迎的分支模型之一是使用合并模型的git flow。
http://nvie.com/posts/a-successful-git-branching-model/ http://nvie.com/posts/a-successful-git-branching-model/
The essence of the git flow model is the use of master, release, develop, and feature branches (among others) to organise the state that your code is in. With this model it should be easy to tell when to merge, as it will be at certain stages, for example: a feature is complete or you are going to do your next release. git flow模型的本质是使用master,release,develop和feature分支(以及其他)来组织代码所处的状态。使用此模型,应该很容易分辨何时合并,因为它将处于某些阶段,例如:功能已完成,或者您将要发布下一个版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.