Javascript 如何使用nodegit在本地创建分支、setUpStream和推送新更改?
我已连接到git repo createdbranch,已在本地签出。现在我想将此分支设置为上游分支,并使用新更改推送到远程repo,返回错误键。未找到任何帮助将不胜感激 main.jsJavascript 如何使用nodegit在本地创建分支、setUpStream和推送新更改?,javascript,node.js,git,nodegit,Javascript,Node.js,Git,Nodegit,我已连接到git repo createdbranch,已在本地签出。现在我想将此分支设置为上游分支,并使用新更改推送到远程repo,返回错误键。未找到任何帮助将不胜感激 main.js const nodegit = require('nodegit'); const createBranch = function(data){ const branchName = "nodegitBranchTest"; console.log(
const nodegit = require('nodegit');
const createBranch = function(data){
const branchName = "nodegitBranchTest";
console.log("PROMISE4", data.commit);
return data.repo.createBranch(branchName, data.commit, 1).then(function(res){
console.log("RES>>>>>", res.name());
return {data , res , branchName};
});
}
const checkOutBranch = function(data){
const branchName = data.branchName;
return repo.checkoutBranch(branchName).then(function(ref){
return ref;
});
}
const setUpstream = function (obj) {
// ob.ref is branch reference locally 'ref/remote/heads/newBranch
return nodegit.Branch.setUpstream(obj.res, obj.res);
}
nodegit.Repository.open(dir)
.then(createBranch)
.then(checkOutBranch)
.then(setUpstream)
.then(function(res){
console.log("PROMISE5", res);
})
.catch(function(err){
console.log("ERRR>>>>>>>", err);
});
错误
[Error: could not find key 'branch.nodegitBranchTest.remote' to delete] errno: -1, errorFunction: 'Branch.setUpstream' }