I have a NodeGit repository object, repo
, and a string sha
code which represents a commit id, commit_id
. How can I perform a git checkout of this commit using NodeGit, which would act the same as the command git checkout $commit_id
?
So far, I have tried creating a Reference
using the commit id and then using checkoutRef
to check out the reference. However, the repository does not change and I get the error Error: the given reference name '<my commit id>' is not valid
.
NodeGit.Reference.lookup(repo, commit_id, (reference) => {
repo.checkoutRef(reference)
});
Thanks for the help.