I'm currently using nodegit to run my git commands and it has worked for everything so far except for deleting a remote branch. I don't mind using another npm package to do this if needed but I would prefer to use nodegit.
Basically, I want a function which can do the same as this command in the terminal
$ git push -d <branch_name>
I want to be able to write something like the following:
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)
})
})
})
}
The documentation for remote.push is here: http://www.nodegit.org/api/remote/#push
Any help would be appreciated. Thanks!
Push an empty src reference to the origin branch.
remote.push(':refs/heads/my-branch');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With