Note that the pygit2 documentation is quite lacking. (If you have any questions, the libgit2 header documentation will help.)
>>> import pygit2
>>> repo = pygit2.Repository('.')
>>> blob_id = repo.create_blob('hogehoge')
>>> builder = repo.TreeBuilder(repo.head.tree)
>>> builder.insert('hoge.txt', blob_id, pygit2.GIT_FILEMODE_BLOB)
>>> newtree = builder.write()
>>> author = pygit2.Signature('methane', 'inada-n [at] klab.com')
>>> repo.create_commit('HEAD', author, author, 'add hogehoge',
newtree, [repo.head.oid])
'\xbc&C\x96\xfb\x84\xc4\x1f\x8a\xbd\xc5h6\x98\x08i\x84\xd4\nf'