git-commit

Initial commit

Add everything, and make an initial commit:

$ git add .
$ git commit -m "Initial commit"
>>> index = repo.index
>>> index.add_all()
>>> index.write()
>>> ref = "HEAD"
>>> author = Signature('Alice Author', 'alice@authors.tld')
>>> committer = Signature('Cecil Committer', 'cecil@committers.tld')
>>> message = "Initial commit"
>>> tree = index.write_tree()
>>> parents = []
>>> repo.create_commit(ref, author, committer, message, tree, parents)

Subsequent commit

Once HEAD has a commit to point to, you can use repo.head.name as the reference to be updated by the commit, and you should name parents:

>>> ref = repo.head.name
>>> parents = [repo.head.target]

The rest is the same:

>>> index = repo.index
>>> index.add_all()
>>> index.write()
>>> author = Signature('Alice Author', 'alice@authors.tld')
>>> committer = Signature('Cecil Committer', 'cecil@committers.tld')
>>> message = "Initial commit"
>>> tree = index.write_tree()
>>> repo.create_commit(ref, author, committer, message, tree, parents)

References