内核的git仓库托管在https://git.kernel.org/,打开这个页面发现这里面有很多的仓库,导致不知道克隆哪一个。
linux内核的仓库是linux.git,有很多的仓库,有些是用来开发feature的,有些是内核核心开发自己fork的。
有3个主要的仓库:
一个是torvalds的mainline仓库:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
一个是稳定版本的仓库
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
一个是next版本的仓库
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
这3个在内核主页,点击相关版本的browser可以找到链接。
克隆:
$ git clone https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
然后同时可以添加stable:
$ git remote add stable https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/
$ git fetch stable
如果在国内克隆速度较慢,可以克隆CAF的北京镜像源[1]。前缀替换即可,如
git://kernel.source.codeaurora.cn/pub/scm/linux/kernel/git/stable/linux.git/
克隆之后,torvalds仓库只有一个master分支,然后有tag,来指定大版本,如:
v5.9
v5.9-rc1
v5.9-rc2
v5.9-rc3
猜测:stable的分支是从这个tag来的。
stable仓库每一个大版本都一个分支,然后具体的版本是tag
remotes/stable/linux-4.0.y 391b01b08db6 Linux 4.0.9
remotes/stable/linux-4.1.y c4ff7514e71d Linux 4.1.52
remotes/stable/linux-4.10.y 17a4d4803381 Linux 4.10.17
remotes/stable/linux-4.11.y bd1a9eb6a755 Linux 4.11.12
remotes/stable/linux-4.12.y fa394784e74b Linux 4.12.14
v5.9.2
v5.9.3
v5.9.4
v5.9.5
v5.9.6
CAF的镜像已经失效了,可以用清华大学的,具体见:
https://mirrors.tuna.tsinghua.edu.cn/help/linux.git/
linux-stable和linux-next也有。
git remote add tsinghua https://mirrors.tuna.tsinghua.edu.cn/git/linux.git
参考
[1] https://www.kernel.org/beijing-git-mirror.html
[3] https://www.kernel.org/doc/man-pages/linux-next.html