为什么 Linux 内核仓库只有一个分支?
Why does the Linux kernel repository have only one branch?
我是 Linux 初学者,如果这是您听过的最明显的问题,请原谅我。
这个 repo 只反映了 Linus 将数百个其他分支合并到一个主 repo 的工作结果。
它不保留那些分支,因为它们太多了:那个 repo 的作用是作为参考。
主线内核
首先:不要使用那个 github link(它只是一个镜像)。实际存储库位于 kernel.org. You probably want to use Linus Torvalds' tree, which is torvalds/linux.git.
它被称为 mainline 内核,这意味着这棵树是下一个内核版本的实际开发发生的地方。虽然它只有 master 分支,但您可以使用标签检出任何内核版本。此命令将显示所有版本标签:
$ git tag
您可以像这样结帐到所需的标签:
$ git checkout v4.0
主线内核不需要一堆分支,因为这棵树中的开发过程永远不会停止,一旦发布新版本,就不会向后移植到那个版本(在主线树中).所以在这种情况下,Linus 坚持使用标签(而不是分支)。
稳定内核
还有linux-stable棵树。 “稳定”意味着在发布后,一些错误修复将被反向移植到它。在这棵树中你应该寻找分支(而不是标签):
$ git branch -a
您可以看到如下分支:
linux-4.9.y
其中 y
后缀只是错误修复版本的占位符(因为命名方案是 linux-4.x.y
)。每当您看到 y
后缀时——它就是一个稳定的内核分支。其中一些分支是 LTS 内核(详情请阅读 this)。
在这种情况下需要分支,因为开发人员必须将一些错误修复反向移植到已发布的版本中。所以这里只有标签是不够的。
下一个内核
还应该提到的是linux-next tree. Here is the description from kernel process documentation:
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.
维护者树
回到树上。实际上有很多,它们被称为维护者树。你可以看到所有这些 here.
您需要了解合并策略:只有 Linus 才能真正将代码合并到主线树中。你可以在 git 日志中看到他的很多 merge commits。所以如果你想让你的补丁应用到主线内核,你需要将它发送到 kernel mailing lists for 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.
如果您有兴趣将补丁上传到上游——您可能还想阅读 kernelnewbies.org 资料。
我是 Linux 初学者,如果这是您听过的最明显的问题,请原谅我。
这个 repo 只反映了 Linus 将数百个其他分支合并到一个主 repo 的工作结果。
它不保留那些分支,因为它们太多了:那个 repo 的作用是作为参考。
主线内核
首先:不要使用那个 github link(它只是一个镜像)。实际存储库位于 kernel.org. You probably want to use Linus Torvalds' tree, which is torvalds/linux.git.
它被称为 mainline 内核,这意味着这棵树是下一个内核版本的实际开发发生的地方。虽然它只有 master 分支,但您可以使用标签检出任何内核版本。此命令将显示所有版本标签:
$ git tag
您可以像这样结帐到所需的标签:
$ git checkout v4.0
主线内核不需要一堆分支,因为这棵树中的开发过程永远不会停止,一旦发布新版本,就不会向后移植到那个版本(在主线树中).所以在这种情况下,Linus 坚持使用标签(而不是分支)。
稳定内核
还有linux-stable棵树。 “稳定”意味着在发布后,一些错误修复将被反向移植到它。在这棵树中你应该寻找分支(而不是标签):
$ git branch -a
您可以看到如下分支:
linux-4.9.y
其中 y
后缀只是错误修复版本的占位符(因为命名方案是 linux-4.x.y
)。每当您看到 y
后缀时——它就是一个稳定的内核分支。其中一些分支是 LTS 内核(详情请阅读 this)。
在这种情况下需要分支,因为开发人员必须将一些错误修复反向移植到已发布的版本中。所以这里只有标签是不够的。
下一个内核
还应该提到的是linux-next tree. Here is the description from kernel process documentation:
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.
维护者树
回到树上。实际上有很多,它们被称为维护者树。你可以看到所有这些 here.
您需要了解合并策略:只有 Linus 才能真正将代码合并到主线树中。你可以在 git 日志中看到他的很多 merge commits。所以如果你想让你的补丁应用到主线内核,你需要将它发送到 kernel mailing lists for 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.
如果您有兴趣将补丁上传到上游——您可能还想阅读 kernelnewbies.org 资料。