Javascript nodegit cannot find remote

People, I have a branch named user/foo that I would like to check from a remote. The code:

 Git.prototype.refresh = function refresh(branch) { var options = { credentials: function() { return NodeGit.Cred.userpassPlaintextNew(GITHUB_TOKEN, "x-oauth-basic"); }, certificateCheck: function() { return 1; } }; return NodeGit.Repository.open(localPath).then(function (repo) { return repo.checkoutBranch(branch, options).then(function (checkoutresult) { return repo.fetchAll(options).then(function (result) { return Promise.resolve(result); }).catch(function (err) { console.log('Unable to fetch',err); return Promise.reject(new Error(err)); }); }).catch(function(err) { console.log('checkoutBranch',err); return Promise.reject(new Error(err)); }); }); }; 

Error:

 [Error: Error: Reference 'refs/remotes/user/foo/HEAD' not found] 

Am I using checkoutBranch incorrectly? I already have a remote cloned to a local directory, and I'm trying to switch to a specific branch.

Thanks!

+5
source share
1 answer

This is copypasta from Nodegit problem.

This way you can check the local branch. You are trying to check the remote. What you need to do is get a commit on the remote branch , then use it to create a new branch , and then (optionally) set upstream to track the original remote branch.

At this point, you can check your newly created local branch.

+3
source

Source: https://habr.com/ru/post/1216616/


All Articles