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

前端 未结 2 859
情深已故
情深已故 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:31

    Just the gc prune is often not enough to get rid of the extra objects in the repo. If commits are still referenced in the reflog, it won't consider those objects unreachable and hence ripe for pruning.

    Here's what worked for me:

    git reflog expire --expire=now --all
    git gc --aggressive --prune=now
    git repack -a -d -l
    

    This will make some changes to your repo's history, and may well present difficulties if others are depending on the branches you blow away.

    You may have to re-clone your repository to actually see a difference in its size.

提交回复
热议问题