如何解决使用nodegit的checkout分支不起作用?
使用nodegit动态更新分支内容,因此首先在下面的代码中,我尝试将分支切换至未发生的状态,这是repo的分支列表,知道如何实现该任务吗?
main.js
const nodegit = require('nodegit');
const fs = require ('fs')
const getAllBranches = function(repository) {
return repository.getReferenceNames(nodegit.Reference.TYPE.ALL);
}
const checkoutBranch = function (repo,branches) {
for (const branch of branches) {
const master = "master";
if(branch.includes(master)) {
console.log("branch",branch);
repo. checkoutBranch(branch).then(function(ref){
return repo.checkoutRef(ref)
});
}
}
}
nodegit.Repository.open(dir)
.then(getAllBranches)
.then(function(branches ){
return checkoutBranch(dir,branches);
})
.then(function(branch){
console.log("checkout",branch);
})
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。