我应该将master合并到功能分支中以使其更新吗?这会被视为不良做法吗? [英] Should I merge master into a feature branch to bring it up to date? Would this be considered bad practice?

查看:173
本文介绍了我应该将master合并到功能分支中以使其更新吗?这会被视为不良做法吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这样的情况:

            (master)
A - B - E - F
      \       
        C - D
            (feature-x)

如果我需要将关键修补程序E和F合并到feature-x分支以继续开发,并且打算将其合并回master,是否应该将master合并到feature-x中?

Should I merge master into feature-x if I need critical fixes E and F into the feature-x branch to continue development and I intend to merge back into master?

重复将master合并到功能分支中,然后在该功能分支可能与其他开发人员共享或不共享时,将功能重新合并回master是否有任何不利之处?

Is there any disadvantage to repeated merging master into a feature branch and then the feature back into master when the feature branch might or might not be shared with other developers?

推荐答案

据我了解,将master合并到您的功能分支中不算是坏习惯. @larsks的答案给出了一些有关如何使用重定基的好的信息,这是一个选择.但是请确保遵循黄金法则不要对存储库外部存在的提交进行重新基准设置"

So far as I understand, merging master into your feature branch isn't considered bad practice. @larsks answer gives some good info about how to use rebasing which is an option. But be sure to follow the golden rule "Do not rebase commits that exist outside your repository"(see Perils of rebasing).

要澄清:存在于存储库外部的提交"将是公共(推送)提交.

To clarify: 'commits that exist outside your repository' would be public (pushed) commits.

如果您想知道重新合并是否比合并或反之更好,则建议您查看以下内容:.本文指出,解决方案取决于您和您的团队认为最适合您的项目的情况.

If you wonder whether rebasing, is better than merging or vise versa, I would suggest you look over: 'Rebase vs. Merge'. The article points out that the answer to this is dependent on what you and your team think is best for your project.

对于较大的项目,我喜欢历史来准确显示发生了什么.因此,在我工作的地方,我们通常将master合并到功能分支中,以使它们与最新代码保持最新.不过,我不一定会认为这是每个人的全球最佳做法.但是,这也不被认为是不好的做法.

For larger projects, I like the history to show exactly what happened. So where I work, we usually merge master into our feature branches to get them up to date with the latest code. Though, I wouldn't necessarily consider this a global best practice for everyone. However, it's not considered bad practice either.

另一些​​人希望拥有非常干净的历史记录,因此对他们而言,重新定级可能被认为是更好的选择.

Some others like to have very clean history, so for them rebasing may be considered the better option.

这篇关于我应该将master合并到功能分支中以使其更新吗?这会被视为不良做法吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆