Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove mysterious ref from Git

After a filter-branch and prune/gc, there are still some undesired commits.

They aren't on the branches I care about; there must be some tags or something holding onto them.

I'm trying to figure out what that is, and remove it.

But nothing I try seems to work.

$ git name-rev 1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f #what's holding on?
1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f original/refs/tags/1.0-rc80~1320^2~8^2~1
$ git rm -r refs/original
$ git name-rev 1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f
1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f original/refs/tags/1.0-rc80~1320^2~8^2~1
$ git update-ref -d original/refs/tags/1.0-rc80
$ git name-rev 1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f
1bdac1e1ad7ec61a4b05d3f91eb39bde61a4da1f original/refs/tags/1.0-rc80~1320^2~8^2~1

(This is in a bare repo.)

How do I remove original/refs/tags/1.0-rc80, whatever that is?

like image 700
Paul Draper Avatar asked Mar 22 '26 10:03

Paul Draper


1 Answers

The full name is refs/original/refs/tags/1.0-rc80 and it lives in the refs/original name space. You were very close with this command:

git update-ref -d original/refs/tags/1.0-rc80

except that update-ref requires that you spell out the full name, refs/original/refs/tags/1.0-rc80.

You may have some additional refs/original/* names since git filter-branch copies any ref names there before changing them. You can see them all with:

git for-each-ref refs/original

(and you can even use for-each-ref to generate commands to remove them, or you can just rm -rf .git/refs/original and edit .git/packed-refs directly, but the for-each-ref method is more likely to work in the future if/when refs are packed differently or something, plus you mentioned that this is a bare repo so they're not in .git here...).

like image 182
torek Avatar answered Mar 24 '26 23:03

torek



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!