Search code examples
javascriptgitnodegit

How to reset staged and unstaged changes with nodegit


I'm trying to execute git reset --hard via nodegit after setting the HEAD to a detached state by doing the following:

var oid = 'commit sha';
repo.setHeadDetached(oid);
Reset.reset(repo, oid, Reset.TYPE.HARD);

but without any success.

  • Am I doing something wrong?
  • Am I missing a step?

Solution

  • From the documentation:

    Look here (searched the project for such a method):
    https://github.com/nodegit/nodegit/search?utf8=%E2%9C%93&q=detach

    Another related issue:
    https://gitter.im/nodegit/nodegit/archives/2015/04/13