How to connect to git repo and create branch using nodegit?

460 Views Asked by At

I am trying to connect to my git repo through code wanted to create branch dynamically , using nodegit to achieve this task it is throwing an error No file or directory found.

Need help with following task with nodegit :

1- Connect to git repo by passing my credentials

2- create a branch and set that as upstream

open.js

Git.Repository.open(path.resolve(__dirname, "https://gitw.dgital-1.com/digital//myproject"))
    .then(function(repo) {
      // Create a new branch on head
      console.log("REPO", repo);
      return repo.getHeadCommit()
      .then(function(commit) {
        return repo.createBranch(
          "new-branch",
          commit,
          0);
      });
    });
0

There are 0 best solutions below