dangling objects are data that are stored in the repository but can not be reached by normal means because no branch or tag points to them.
It is natural to have these objects in your repository over time because they are Git's means to ensure that you do not lose any information even if you make a mistake or regret some action.
There are two types of dangling data: blob and commit .
dangling commits are commits that belong to some branch or tag, but this branch / tag has been removed from the repository. Git keeps these commits within the repository, but they are not naturally reachable.
The dangling blobs are data that are in the staging area ) but the user never commitou. They also have a hash because when you do a git add
git already calculates SHA-1
of content.
However, these objects do not stay in the repository forever. Git runs, from time to time, a git gc
to make a cleaning and optimization in the repository, removing objects that are in this state and that are older than 2 weeks.