7

I have a bare git repository that, according to git fsck --full, has about 300 dangling commits and tags. About 90% of it are dangling tags.

I'm not sure where these issues come from, but since the repository seems to work fine, they might have been there for a while already.

I would like to fix them, but so far nothing I tried made the issues go away. So far I have tried these commands:

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

How can I fix these dangling commits and tags? Are they a problem at all? It is important that I don't lose the history and tags and I'm a bit concerned about the many dangling tags.

Best regards

2

1 Answer 1

3

Dangling commits and tags are commits and tags which are not "reachable" which means that they are not the part of the history of HEAD or any branch. If and only if you currently do not miss any commit, then you can remove them. To delete dangling commits, DrZoo has already posted a good link. Deleting tags using git can be a little bit tricky sometimes. But You can also remove tags manually. If git says you have a

dangling tag b61fdaf08acb1412b629b1913da21143775e523a

for example then you can remove this by removing the file

repositoryfolder\.git\objects\b6\1fdaf08acb1412b629b1913da21143775e523a
1
  • .git\objects does not seem to contain such objects after gc (git 2.25.1) ├── lost-found │   ├── commit │   │   ├── 248eba3d3eb468f568e281a30c2baa38118a08d5 ... │   │   └── cb466b9f92d9164c7eb27acb6e6185066fe7cf3a │   └── other │   ├── 0025ed61b844057da4ed9b149ad3533bc067af5d ... │   └── efa6dfa5b4d56670daad211c91c8ddb98e392330 ├── objects │   ├── info │   │   ├── commit-graph │   │   └── packs │   └── pack │   ├── pack-43fc3ebfb008ea685aa0a82c4bbe875f6857c3e8.idx │   └── pack-43fc3ebfb008ea685aa0a82c4bbe875f6857c3e8.pack ├── ORIG_HEAD
    – axd
    Commented Apr 21, 2023 at 5:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .