簡體   English   中英

如何使用nodegit刪除遠程分支?

[英]How to remove a remote branch with nodegit?

我試圖在未定義src的情況下推送refspec,但它不會刪除遠程分支。 這是我的代碼的樣子

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}`);
    }) 

結果在我的控制台中:

done

您對我如何刪除遠程分支有什么建議? 謝謝

將空的src引用推送到origin分支,例如:

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

對於您的代碼集參考:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM