如何在本地创建分支,setUpStream并使用nodegit推送新更改?

问题描述

我已连接到git repo createdbranch,现在已在本地检查checkedOut,我想将此分支设置为上游,并使用新的更改推送到远程repo,返回错误密钥找不到任何帮助。

main.js

      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' }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)