git (ターミナル) でリポジトリのクローンを作成し、nodegit を使用してリモートの開発ブランチにチェックアウトすると、問題なく動作します。しかし、提供された例
を使用して、リモートマスターブランチに戻りたいときに、それを理解できないという問題に遭遇しました。
SSH によるクローン作成
git clone git@mygit.com/projects/myproject.git
開発へのチェックアウトは次のコードで機能しますが、マスター ブランチが既にローカルに存在するため、元に戻すには機能しません。
git.Repository.open(appDir)
.then((repo) => {
return repo.getHeadCommit()
.then((targetCommit) => {
return repo.createBranch(repositoryConfig.branch, targetCommit, false);
})
.then((reference) => {
return repo.checkoutBranch(reference, {});
})
.then(() => {
return repo.getReferenceCommit('refs/remotes/origin/' + repositoryConfig.branch);
})
.then((commit) => {
git.Reset.reset(repo, commit, 3, {});
})
.catch((err) => {
reject(err);
});
})
.then(() => {
resolve('Checking out branch ' + repositoryConfig.branch + ' done');
})
.catch((err) => {
reject(err);
});
ローカル コピーをマスター ブランチにリセットするこのコードで試してみましたが、それを "フォロー" しませんでした。
git.Repository.open(appDir)
.then((repo) => {
return repo.getBranch('refs/remotes/origin/' + repositoryConfig.branch)
.then((reference) => {
return repo.checkoutBranch(reference, {});
})
.then(() => {
return repo.getReferenceCommit('refs/remotes/origin/' + repositoryConfig.branch);
})
.then((commit) => {
git.Reset.reset(repo, commit, 3, {});
})
.catch((err) => {
reject(err);
});
})
.then(() => {
console.log('Checking out branch ' + repositoryConfig.branch + ' done');
resolve();
})
.catch((err) => {
reject(err);
});
で、repositoryConfig.branch
切り替えを有効にするようにブランチを設定しました。
私は完全に git に興味があるわけではありません。
ですから、どんな助けにも感謝します。