git 为什么Linux内核库只有一个分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30268332/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does the Linux kernel repository have only one branch?
提问by Robin
I'm a Linux beginner, so forgive me if this is the most obvious question you've ever heard.
我是 Linux 初学者,如果这是您听过的最明显的问题,请原谅我。
回答by Sam Protsenko
Mainline kernel
主线内核
First of all: don't use that github link (it's just a mirror). The actual repositories are located at kernel.org. You probably want to use Linus Torvalds' tree, which is torvalds/linux.git.
首先:不要使用那个 github 链接(它只是一个镜像)。实际存储库位于kernel.org。您可能想使用 Linus Torvalds 的树,即torvalds/linux.git。
It's called mainlinekernel, which means this tree is the one where actual development of next kernel version is happening. Although it has only masterbranch, you can checkout to any kernel version using tags. This command will show you all version tags:
它被称为主线内核,这意味着这棵树是下一个内核版本的实际开发发生的地方。虽然它只有master分支,但您可以使用标签检出任何内核版本。此命令将显示所有版本标签:
$ git tag
You can checkout to desired tag like that:
您可以像这样结帐到所需的标签:
$ git checkout v4.0
There is no need in a bunch of branches for mainline kernel, as development process in this tree never stops, and once new version is released, there won't be any back-porting to that version (inside mainline tree). So Linus sticks to tags (instead of branches) in this case.
主线内核不需要一堆分支,因为这个树中的开发过程永远不会停止,并且一旦发布新版本,将不会有任何向后移植到该版本(在主线树内)。所以在这种情况下,Linus 坚持使用标签(而不是分支)。
Stable kernel
稳定的内核
There is also linux-stabletree. "Stable" means that after release, some bug fixes would be back-ported to it. In this tree you should look for branches (rather than tags):
还有linux-stable树。“稳定”意味着发布后,一些错误修复将向后移植。在这棵树中,您应该寻找分支(而不是标签):
$ git branch -a
You can see branches like:
您可以看到以下分支:
linux-4.9.y
where y
suffix is just a placeholder for a bugfix version (because naming scheme is linux-4.x.y
). Whenever you see y
suffix -- it's a stable kernel branch. Some of those branches are LTS kernels (read thisfor details).
其中y
后缀只是错误修复版本的占位符(因为命名方案是linux-4.x.y
)。每当您看到y
后缀时——它就是一个稳定的内核分支。其中一些分支是 LTS 内核(阅读本文了解详细信息)。
In this case branches are needed because developers have to backport some bug fixes into released versions. So just tags are not enough here.
在这种情况下需要分支,因为开发人员必须将一些错误修复向后移植到已发布的版本中。所以这里只有标签是不够的。
Next kernel
下一个内核
It also should be mentioned that there is linux-nexttree. Here is the description from kernel process documentation:
还应该提到的是,有linux-next树。以下是内核进程文档中的描述:
Before updates from subsystem trees are merged into the mainline 4.x tree, they need to be integration-tested. For this purpose, a special testing repository exists into which virtually all subsystem trees are pulled on an almost daily basis:
https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
This way, the
-next
kernel gives a summary outlook onto what will be expected to go into the mainline kernel at the next merge period. Adventurous testers are very welcome to runtime-test the-next
kernel.
在将子系统树的更新合并到主线 4.x 树之前,需要对它们进行集成测试。为此,存在一个特殊的测试存储库,几乎每天都会将所有子系统树拉入其中:
https://git.kernel.org/?p=linux/kernel/git/next/linux-next.git
通过这种方式,
-next
内核对在下一个合并期间预计将进入主线内核的内容进行总结。非常欢迎有冒险精神的测试人员对-next
内核进行运行时测试。
Maintainer trees
维护者树
Back to the trees. Actually there are many of them, they are called maintainers trees. You can see all of them here.
回到树上。实际上有很多,它们被称为维护者树。你可以在这里看到所有这些。
You need to understand merging policy: only Linus can actually merge code to the mainline tree. You can see a lot of merge commitsfrom him in git log. So if you want your patch to be applied to mainline kernel, you need to send it to kernel mailing listsfor review first. See Documentation/SubmittingPatches. Once your patch is reviewed and acknowledged by corresponding subsystem maintainer, he will apply it to his own tree. From there this patch will be merged to mainline kernel during next merge window. Linux kernel development model is described here.
您需要了解合并策略:只有 Linus 才能真正将代码合并到主线树中。你可以在 git log 中看到他的很多合并提交。因此,如果您希望将补丁应用于主线内核,则需要先将其发送到内核邮件列表以供审核。请参阅文档/提交补丁。一旦你的补丁被相应的子系统维护者和确认,他就会将它应用到他自己的树上。从那里这个补丁将在下一个合并窗口中合并到主线内核。此处描述了Linux 内核开发模型。
If you are interested in upstreaming your patches -- you may also want to go through kernelnewbies.orgmaterials.
如果您对上游补丁感兴趣——您可能还想浏览kernelnewbies.org材料。
回答by VonC
This repo only reflects the result of Linus' work merging hundreds of other branches into one main repo.
这个 repo 只反映了 Linus 将数百个其他分支合并到一个主 repo 的工作结果。
It does not keep those branches because there would be too many of them: the role of that repo is to be a reference.
它不会保留这些分支,因为它们会太多:该 repo 的作用是作为参考。