不在Git的主分支上工作的原因 [英] Reasons for not working on the master branch in Git

查看:111
本文介绍了不在Git的主分支上工作的原因的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我对git相当陌生,在过去的几周里我阅读了一些内容,我已经阅读了一些人说,主分支不应该改变,而应该从然后合并到。



我很高兴能够与分支机构合作,但想知道不支持master分支的原因吗?

解决方案

我想通常的推理是,主分支应该代表你的代码的'stable'历史。使用分支来实验新功能,实现它们,当它们已经足够成熟时,可以将它们合并回主。

这样,master中的代码几乎总是会生成问题,并且可以直接用于发布。



让我们以git.git(官方git存储库)为例。有几个分支,最明显的:



所以, master 包含的代码很可能会在下一个版本的git中结束。 下一步包含经过测试的代码,这些代码可能会合并到 master 分支中。 pu (建议更新,iirc)包含相当新的(也可能)未经测试的代码。

pu 被认为是不稳定的,将被重新设置并重新设置为junio的喜好。 下一步可能会在发布后或发布周期后重置,但这种情况不太常见。 master 被设置为一成不变,并且在被推送并公开可用之后永远不会改变。

将从 pu 下一个以及从下一个 master 如果它们被认为是有价值的并且不会破坏东西。

分支 maint 用于进行错误修正,这些错误修正也适用于旧版本的git。 maint 通常会合并为下一个和/或 master

您可以在上查看分行http://git.kernel.org/?p=git​​/git.git;a=summary


So, I'm fairly new to git and I've after a bit of reading around over the last couple of weeks I've read a few people saying that the master branch shouldn't be changed but rather branched from and then merged to.

I'm happy enough to work with branches but was wondering for the reasons behind not working on the master branch?

解决方案

i guess the usual reasoning is, that the master branch should represent the 'stable' history of your code. use branches to experiment with new features, implement them, and when they have matured enough you can merge them back to master.

that way code in master will almost always build without problems, and can be mostly used directly for releases.

let's take git.git (the official git repository) as an example. there are several branches, most noticable:

so, master contains code which is very likely to end up in the next release of git. next contains tested code, which will potentially be merged into the master branch. pu (proposed updates, iirc) contains quite new (and probably) untested code.

pu is considered unstable and will be reset and rebased to junio's liking. next might get reset after a release or during a release cycle, but this is less common. master is set in stone and never changed after it's been pushed and made publicly available.

you see, that changes will get merged from pu to next and from next to master if they are deemed worthy and don't break stuff.

the branch maint is used to make bugfixes which should also apply to older versions of git. maint is usually merged to next and/or master.

you can inspect the branches on http://git.kernel.org/?p=git/git.git;a=summary

这篇关于不在Git的主分支上工作的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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