git-add, git-commitを使わずにコミットする方法

cf.) Git Internals - Git Objects

  1. blobオブジェクトを作る
  2. treeオブジェクトを作る
  3. commitオブジェクトを作る

blobオブジェクトを作る

$ echo 'hello world' > test
$ git hash-object -w test
# 3b18e512dba79e4c8300dd08aeb37f8e728b8dad

treeオブジェクトを作る

$ printf "100644 blob 3b18e512dba79e4c8300dd08aeb37f8e728b8dad\ttest" | git mktree
# 5b873f747ccb268e4491f289eb37fc675ff5825b

もしくは

$ git write-tree
# 5b873f747ccb268e4491f289eb37fc675ff5825b

commitオブジェクトを作る

$ echo "first commit" | git commit-tree 5b873f747ccb268e4491f289eb37fc675ff5825b
# 6684f9fdfbdd60db2ba2851c97aa08aa76ad9487
$ git log 6684f9fdfbdd60db2ba2851c97aa08aa76ad9487