簡體   English   中英

使用git刪除不在本地存儲庫中的分支

[英]Delete branches which are not in the local repository using git

當我在GitHub上分叉時,我的git repo上有一堆分支。 我不希望我的GitHub fork擁有這些分支。

有什么方法可以刪除我的GitHub倉庫中不在我本地倉庫中的所有分支嗎?

git push --mirror <origin>將使遠程的refs與本地存儲庫中的refs匹配,包括刪除本地沒有的分支。

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.

你可以刪除遠程分支我推空分支:

$ git push origin :branch-to-delete

暫無
暫無

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

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