非常感谢nodegit的一些帮助。我用它来检查分支(branch-development-modular-alpha-2.0.0
):
var cloneRepo = nodegit
.Clone(cloneURL, repoPath, cloneOptions)
.then(function (repo) {
repo.getBranch('refs/remotes/origin/' + branch).then(function(reference) {
repo.checkoutRef(reference);
// Go through repo's submodules
nodegit.Submodule.foreach(repo, function (submodule) {
var submoduleName = submodule.name();
var submoduleURL = submodule.url();
var submodulePath = repoPath + "/" + submodule.path();
// Clone the submodule
nodegit
.Clone(submoduleURL, submodulePath, cloneOptions)
.then(function (repo) {
// TODO: DO SOMETHING.
})
})
})
})
现在我想从同一个分支中提取更改,但是我有类似的东西,但它没有使用分支的最新更改进行更新。
nodegit
.Repository
.open(path.resolve(__dirname, repoPath))
.then(function (repo) {
existingRepository = repo;
return existingRepository.fetchAll(cloneOptions.fetchOpts);
})
.then(function () {
return existingRepository.mergeBranches('master', 'refs/remotes/origin/' + branch);
})
.catch(function(error) {
console.log(error);
})
我做错了什么?
答案 0 :(得分:0)
拉取是一个fetch + merge。
除了合并将是原始/主人到主人 或者起源/分支到分支。
在您的情况下,nodegit merge
function调用应为:
return existingRepository.mergeBranches(branch, 'refs/remotes/origin/' + branch);
由于Jamie Counsell添加in the comments:
我也遇到了这个错误。
最终结果是因为我正在使用
nodegit
检索分支名称,它提供的内容类似于origin/refs/heads/master
,而不仅仅是master
。致电
branch.shorthand()
让我"master
"