git daemon on Windows

Windows machine で管理してた git repository を Macbook Air に持ってくのどうすんべかなーと思ってたんだけど git repository を楽に他の host に公開できるみたいなので Windows の repository 公開 -> Macbook Air で clone ができるか試してみた。っても git daemon を叩くだけなので難しいことはないんだけどいくつか注意点があるので書く。

あーうーんいくつか注意点というか git daemon の性質を把握しとけというだけなんだけど。環境は Windows XP の msysgit 1.7.4 preview

  • git daemon を実行すると server process が立ち上がる。
    • Control+C で殺しても、というか殺したつもりでも port 9418 をがっちりつかんだままの process がいるのでそいつを task manager あたりで終了させないと設定を変えての再起動ができない。
    • server process がいる状態で git daemon を叩くと "fatal: unable to allocate any listen sockets on port 9418" とか言われるんだけど、これが port 9418 をつかんじゃってる状態。
    • で、 command line option を変えて起動しなおしたい場合は事前に task manager で "git-daemon.exe" を終了させる。
  • "--base-path" option で他 host からの root path を指定する
    • "--base-path" option を指定しないで実行すると多分 drive 指定からしないと git repository に access できない。
    • で、こいつにたとえば --base-path=/C/Document\ and\ Settings/username/My\ Documents/repos とか指定してやると My Documents 直下の "repos" folder 以下に存在する git repository に access できる。
    • 上記の option で起動した場合 git repository を公開してる host が 192.168.1.1 の IP を持ってるとき、 "%MY_DOCUMENTS%\repos\test.git" を clone するには git clone git://192.168.1.1/test.git と叩く。 "%MY_DOCUMENTS%\repos\folder\another.git" は git clone git://192.168.1.1/folder/another.git でおk。

git repository を公開するための設定やなんかは git daemon の man とか web 上の resource あさればいくらでも出てくるので書かない。

かなり手軽に git repository のやりとりができるので security 考えなくていい場合はこれでやりとりしちゃうのがいいかも。