Tuesday 23 May 2017

Error: failed to read index: 'C:\Users\username\Desktop\test_repo\.git' no longer exists at Error (native) errno: -1

I am fairly new to nodegit as well as node.js and am struggling to understand what this error means.

I've expected addByPath to take the path of my file as a parameter and that it will then add it to the files to be committed. In other words "git add hey.txt".

But so far, I keep getting

Error: failed to read index: 'C:\Users\username\Desktop\test_repo.git' no longer exists at Error (native) errno: -1

Here is all the code you need to replicate the issue. You will need to create a repository on your desktop called test_repo and have an untracked file called hey.txt to replicate the issue. You also need to npm install nodegit. Also, I'm on Windows.

Any help greatly appreciated!

var Git = require("nodegit");
var fs = require('fs');

Git.Index.open("C:\\Users\\firstname lastname\\Desktop\\test_repo\\.git\\index").then(function(index) {
    console.log(index.path());
    return index.addByPath("C:\\Users\\firstname lastname\\Desktop\\test_repo\\hey.txt");
  }).then(function(result) { 
    console.log(result);
  }).catch(function(reasonForFailure) {
  console.log(reasonForFailure);
});



via Wild dog

No comments:

Post a Comment