我目前使用nodegit來運行我的git命令,它除了刪除一個遠程分支以外,一直工作到目前爲止。如果需要,我不介意使用另一個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」]會刪除遠程分支。 –