私は現在、gitコマンドを実行するのにnodegitを使用しています。リモートブランチを削除することを除いて、これまでのところすべてで動作しています。必要に応じて別のnpmパッケージを使用しても構いませんが、nodegitを使用することをお勧めします。Node.jsを使用してリモートブランチを削除する方法は?
基本的に、私は、次のようなものを書くことができるようにしたいターミナルに
$ git push -d <branch_name>
を、このコマンドと同じ操作を行うことができます機能が欲しい:
function delete_remote_branch(repo, branch_name, callback) {
repo.getRemote('origin').then(function(remote) {
repo.getBranch(branch_name).then(function(reference) {
// delete the branch
repo.push("-d :"+reference, branch_name).then(function(error_code) {
if(error_code) {
return callback(error_code)
}
return callback(null)
})
})
})
}
ドキュメントについてremote.pushはここにあります:http://www.nodegit.org/api/remote/#push
何か助けていただければ幸いです。ありがとう!
参照を削除するには、gitのpushコマンドと同様に、空のローカル参照をプッシュします。したがって、[":refs/heads/branch_name"]を押すと、リモートのブランチが削除されます。 –