Fix dangling commits and tags in a git repository
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
Related videos on Youtube
Timo Kunze
Updated on September 18, 2022Comments
-
Timo Kunze over 1 year
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
-
DrZoo about 5 years
-
Timo Kunze about 5 yearsOkay, so it seems better to ignore it. Thank you!
-