我有两个分支从我的系统 Master 和 Dev 中 checkout 。
我的工作目录是 Master 从 Master 我想在知道差异后将文件推送/合并到 dev。
例如,在 Master 中,我正在处理 abc.txt 文件,我想检查 dev 中存在的文件与 master 中存在的文件之间的差异。 我该怎么做?
收到此错误
error while pushing == Error: no reference found for shorthand 'dev' (node:93479) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: no reference found for shorthand 'dev'
代码
differenceCommit(fileName,branchName) {
return new Promise(function (resolve,reject) {
let repo,
changes;
open("./master")
.then(function (repoResult) {
repo = repoResult;
return repo;
})
.then(function (commitId) {
return repo.getBranchCommit("dev");
})
///Difference Before Push
.then(function (commit) {
return commit.getDiffWithOptions("dev");
})
.then(function (diffList) {
console.log("************************");
});
}
最佳答案
将 origin/
添加到分支名称:
differenceCommit(fileName,branchName) {
return new Promise(function (resolve,reject) {
let repo,
changes;
open("./master")
.then(function (repoResult) {
repo = repoResult;
return repo;
})
.then(function (commitId) {
return repo.getBranchCommit("origin/dev");
})
///Difference Before Push
.then(function (commit) {
return commit.getDiffWithOptions("origin/dev");
})
.then(function (diffList) {
console.log("************************");
});
}
关于node.js - NodeGit如何获取另一个分支的最后提交ID?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45712721/