Skip to content

Instantly share code, notes, and snippets.

@lig
Created March 30, 2020 09:15
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lig/dc1ede7e09488a62116fe90aa31617d9 to your computer and use it in GitHub Desktop.
Save lig/dc1ede7e09488a62116fe90aa31617d9 to your computer and use it in GitHub Desktop.
pygit2 create commit simple
import pygit2
repo = pygit2.Repository(path='.')
repo.index.add_all()
repo.index.write()
tree = repo.index.write_tree()
parent, ref = repo.resolve_refish(refish=repo.head.name)
repo.create_commit(
ref.name,
repo.default_signature,
repo.default_signature,
"Commit message",
tree,
[parent.oid],
)
@karolzlot
Copy link

@lig
Copy link
Author

lig commented Oct 28, 2021

@karolzlot Thanks! But this goes beyond the purpose of this gist.

@connorfuhrman
Copy link

Thank you for posting this!! Very helpful in a module I'm writing. PyGit2 is severely under documented....

Copy link

ghost commented Apr 3, 2023

Thank you for posting this!! Very helpful in a module I'm writing. PyGit2 is severely under documented....

It is still very badly documented. I must write custom git server as a part of web ide project of for final project course. Can anybody recommend some good docs, please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment