简体   繁体   中英

How to remove a remote branch with nodegit?

I tried to push the refspec without src defined and it doesn't remove the remote branch. Here's what my code look like

var refs = [
    ':refs/remotes/origin/branch-a'
];

Git.Repository.open(workingPath)
    .then((repository) => {
        return repository.getRemote('origin')
    })
    .then((remote) => {

        return remote.push(refs, {
            callbacks: {
                credentials: function(url, userName) {
                    return Git.Cred.userpassPlaintextNew(username, password)
                }
            }
        })
    })
    .then(() => {
        console.log('done');
    })
    .catch((err) => {
        console.log(`Error: ${err}`);
    }) 

The result in my console:

done

Do you have any suggestion how I could remove the remote branch? thanks

Push an empty src reference to the origin branch, like:

remote.push(':refs/heads/my-branch');//it's a string not an array

For your code set refs:

var refs = ':refs/remotes/origin/branch-a';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM