How to checkout a revision by SHA-1 hash with pygit2?

744 views Asked by At

It is seems that Repository.checkout can only checkout a referenece.
Can we checkout any revision in the repo by SHA1-hash?
equivalent to "svn checkout -r" in subversion system

1

There are 1 answers

1
Carlos Martín Nieto On

The Repository.checkout() method does only accept references or reference names, but that's by far not the only checkout method. There's Repository.checkout_tree() which lets you specify which treeish you want to check out (so you can pass a tree, a commit or a tag).