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

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

问题描述

所以,我对 git 还很陌生,在过去几周阅读了一些资料后,我读到一些人说不应该更改 master 分支,而是应该从 和然后合并到.

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?

推荐答案

我想通常的推理是,master 分支应该代表代码的稳定"历史.使用分支来试验新功能,实现它们,当它们足够成熟时,您可以将它们合并回 master.

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.

这样,master 中的代码几乎总是可以毫无问题地构建,并且大多数情况下可以直接用于发布.

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

我们以 git.git(官方 git 存储库)为例.有几个分支,最引人注目的是:

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

所以,master 包含的代码很可能会出现在下一个 git 版本中.next 包含经过测试的代码,这些代码可能会被合并到 master 分支中.pu(建议更新,iirc)包含相当新的(并且可能)未经测试的代码.

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 被认为是不稳定的,将根据 junio 的喜好进行重置和重新定位.next 可能会在发布后或在发布周期期间重置,但这种情况不太常见.master 是一成不变的,在推送并公开发布后永远不会改变.

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.

你看,这些变化将从 pu 合并到 next 和从 next 合并到 master 如果它们被认为是有价值的,不要破坏东西.

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.

分支 maint 用于修复错误,这些错误修复也应该适用于旧版本的 git.maint 通常合并到 next 和/或 master.

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.

你可以在 http://git.kernel.org/?p 上检查分支=git/git.git;a=摘要

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

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