未来のいつか/hyoshiokの日記

hyoshiokの日々思うことをあれやこれや

Linusが2週間でgitを作った話。

Linuxとgitを作ったLinus - 未来のいつか/hyoshiokの日記という日記がとんでもなく読まれていてビビる。ブックマークもいっぱいついた。はてなブックマーク - Linuxとgitを作ったLinus - 未来のいつか/hyoshiokの日記
Linusがgitを2週間で作ったという話はわりと知られていなかったようなので、その話である。

gitっていつから作られているのだろうか。ということで、本家のリポジトリから引っ張ってくる。

$ git clone https://github.com/git/git

わたしのしょぼいネット環境でも2分はかからない。

最初の10個のコミットは次のようになる。

$ git log --oneline|tail
9426167 Add "-lz" to link line to get in zlib.
7660a18 Add new fsck-cache to Makefile.
2022211 Add first cut at "fsck-cache" that validates the SHA1 object store.
2ade934 Add "check_sha1_signature()" helper function
24778e3 Factor out "read_sha1_file" into mapping/inflating/unmapping.
19b2860 Use "-Wall -O2" for the compiler to get more warnings.
bf0c6e8 Make "cat-file" output the file contents to stdout.
e497ea2 Make read-tree actually unpack the whole tree.
8bc9a0c Add copyright notices.
e83c516 Initial revision of "git", the information manager from hell

最初の16進数はsha-1ハッシュ値の最初の7桁だ。その後がコミットログを一行で表したもの。
e83c516 Initial revision of "git", the information manager from hell
が最初のコミットになる。

sha-1は一意にコミットを同定できるので、gitのどんなリポジトリでもe83c5163316f89bfbde7d9ab23ca2e25604af290というハッシュ値を持つコミットはgitソースツリーの中で最初のコミットになる。

このe83c516のログを見ると下記になる。

$ git log e83c516
commit e83c5163316f89bfbde7d9ab23ca2e25604af290
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date:   Thu Apr 7 15:13:13 2005 -0700

    Initial revision of "git", the information manager from hell

2005年4月7日に最初のバージョンができたことがわかる。

ついでにLinuxの履歴も見てみる。

$ git clone http://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git

こちらも20分ちょっとでcloneが終わった。

$ git log --oneline | tail
e493073 [PATCH] Fix acl Oops
81ddef7 [PATCH] re-export cancel_rearming_delayed_workqueue
9ffb714 [PATCH] crypto: call zlib end functions on deflate exit path
d42ce81 [PATCH] arm: add comment about max_low_pfn/max_pfn
7a228aa [PATCH] arm: add comment about dma_supported()
7aa52f5 [PATCH] arm: fix help text for ixdp465
2d137c2 [PATCH] arm: fix SIGBUS handling
baaa2c5 [PATCH] Avoid deadlock in sync_page_io by using GFP_NOIO
8d38ead [PATCH] mmtimer build fix
1da177e Linux-2.6.12-rc2

git管理されている最初のlinuxのコミットは1da177e Linux-2.6.12-rc2だ。

$ git log 1da177e
commit 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2
Author: Linus Torvalds <torvalds@ppc970.osdl.org>
Date:   Sat Apr 16 15:20:36 2005 -0700

    Linux-2.6.12-rc2
    
    Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.
    
    Let it rip!

4月16日にlinuxソースコードをコミットしている。

'Re: Trivia: When did git self-host?' - MARC
によると、

The first version of git was just ~1300 lines of code, and I have reason 
to believe that I started it at or around April 3rd. The reason: I made 
the last BK release on that day, and I also remember aiming for having 
something usable in two weeks. 

「最初のgitのバージョンはたった1300行たらずだ。そして、開発を始めたのは4月3日ころだと思う。というのは、最後のBKのリリースをその日にしたからで、そして次の二週間でなにか有益なものを作ろうとしたということを覚えている。」

And hosting git itself was not that important for me - hosting the kernel 
was. And the first kernel commit was April 16 (with the first merges being 
a few days later). Which meshes with my "two week goal" recollection.

「gitそれ自体のホスティング(git repositoryに入れること)はそれほど重要ではない、カーネルホスティングは重要だ。そして最初のカーネルのコミットは4月16日で、数日後に最初のマージをした。これが2週間でやるというゴールという記憶にあっている。」

4月3日から開発を始めて、4月7日にはなんらかのものが動いていて、4月16日にはlinuxカーネルを格納できるまでになる。これが2週間足らずでgitを作ったと言われるゆえんである。

それ以来、延々とlinuxの開発は続いていて、

$ git log --oneline | wc -l
456538

45万回以上のコミットされている。

Linus すごいね。