如何使用Node.js删除远程分支?

我目前使用nodegit来运行我的git命令,并且除了删除一个远程分支以外它一直工作到目前为止。 我不介意使用另一个npm包,如果需要的话,但我更喜欢使用nodegit。

基本上,我想要一个function,可以做这个命令在terminal相同

$ 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

任何帮助,将不胜感激。 谢谢!

将一个空的src引用推送到原始分支。

 remote.push(':refs/heads/my-branch');