How to REALLY delete a git branch (i.e. remove all of its objects/commits)?

前端 未结 2 855
情深已故
情深已故 2020-12-08 01:09

I have a git tree like

                 A---B---C topic
                /
           D---E---F---G master     <--

I would like to remove

2条回答
  •  情歌与酒
    2020-12-08 01:50

    Note May 2010: As mentioned by Jakub, if your branch was merged, topic would still be reachable.

    Here, let's suppose there was no merge.
    Then, as mentioned in the ProGit book and detailed in this SO question:

    git gc --prune=now
    

    should be enough (you should call directly git prune). You can control that with a git count-objects -v.
    Edit April 2012: maxschlepzig in the comments confirms that extra steps might be required, as detailed in Duke's answer (but without the git repack).
    So instead of a git gc --prune now:

    git reflog expire --expire=now --all
    git gc --aggressive --prune=now
    

提交回复
热议问题