If I redraw your diagrams to place the branch markers at the tip of the branch (which reflects the actual representation of branches) your original situation is:
o --- C (master)
--- A --- B --- D (feature)
在与<代码>-无-ff合并后 如你所描述,你现在有:
o --- C ------------------ M (master)
/
A --- B --- D (feature)
--- A --- B --- D
根据我的理解,现在请确保<代码>A,B
和D
从您的存放处消失。 首先,我要说,我强烈建议你不要担心这些承诺。
However, if you really want to get rid of them, then you will have to make sure that they are truly unreachable, or git gc --prune=now --aggressive
will not remove them. As it is, they will still be pointed to (at least) by the reflog for feature
. There are various ways of expiring entries from the reflog, e.g. with:
git reflog expire --expire=now feature
... or a safer option should be to set the config variable gc.reflogexpireunreachable
to now
and expire the reflog:
git config gc.reflogexpireunreachable
git reflog expire feature
在这两种情况下,你需要再操作<代码>git gcprune=now——aggressive。
However, to reiterate what I said above, I wouldn t do this - those commits aren t hurting anyone and the reflog is a valuable safety net when using git.