首页 > 解决方案 > 如何连接到 git repo 并使用 nodegit 创建分支?

问题描述

我正在尝试通过想要动态创建分支的代码连接到我的 git 存储库,使用 nodegit 来完成此任务,它抛出错误 No file or directory found。

需要使用 nodegit 完成以下任务的帮助:

1-通过传递我的凭据连接到 git repo

2-创建一个分支并将其设置为上游

打开.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);
      });
    });

标签: javascriptnode.jsgitnodegit

解决方案


推荐阅读