非常感谢有关 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);
})
我做错了什么?
最佳答案
pull 就是获取+ merge 。
除非 merge 是起源/主到主。
或起源/分支到分支。
就您而言,nodegit merge
function那么调用应该是:
return existingRepository.mergeBranches(branch, 'refs/remotes/origin/' + branch);
如Jamie Counsell添加in the comments :
I ran into that error too.
It ends up it was because I was retrieving the branch name using
nodegit
as well, which gave something likeorigin/refs/heads/master
instead of justmaster
.Calling
branch.shorthand()
got me "master
"
关于node.js - 如何使用nodegit从分支中 pull ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49525298/