Gitでブランチをロック(変更不可)する

Git v1.8.2のDocumentationgrepしてもそれっぽい記述はないので、正式な機能じゃないと思う。
gitの内部処理を悪用活用した方法なので、内部処理が変わると使えなくなるかも。
使用は自己責任で

masterブランチのロック

これで、masterブランチの変更(commit, resetなど)が出来なくなる。

$ touch .git/refs/heads/master.lock

コミットしようとすると、下記のようなメッセージが表示される

fatal: Unable to create '/home/sinsoku/Projects/sample/git-sample/.git/refs/heads/master.lock': ??????????.

If no other git process is currently running, this probably means a
git process crashed in this repository earlier. Make sure no other git
process is running and remove the file manually to continue.

indexのロック

ついでに、こっちだとindexを変更できなくなるので、addすら出来なくなる。

$ touch .git/index.lock