开发者

Delete branches which are not in the local repository using git

There's a bunch of branches on one of my git repo's that I got when I开发者_开发技巧 forked it on GitHub. I don't want my GitHub fork to have these branches.

Is there any way that I can delete all the branches on my GitHub repo that are not in my local repo?


git push --mirror <origin> will make the refs on the remote match those in the local repository, including deleting branches that you don't have locally.

From git help push:

--mirror
    Instead of naming each ref to push, specifies that all refs under
    refs/ (which includes but is not limited to refs/heads/,
    refs/remotes/, and refs/tags/) be mirrored to the remote
    repository. Newly created local refs will be pushed to the remote
    end, locally updated refs will be force updated on the remote end,
    and deleted refs will be removed from the remote end. This is the
    default if the configuration option remote.<remote>.mirror is set.


You can delete remote branches my pushing an empty branch:

$ git push origin :branch-to-delete
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜