What is a "dangling object / commit" in git?


My repository has momentarily corrupted after the yesterday's blackout in Brazil . I was able to fix corruption ( so ) and decided to run a git fsck to check the status of my local repository. Here he responds by saying that there are dangling commits :

On another occasion he also told me that there were dangling objects , but I did not save the print.

What is a dangling commit ? Is it related to dangling object ?

How do these things dangling arise?

asked by anonymous 22.03.2018 / 17:20

2 answers


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.

24.07.2018 / 20:30

Basically, as you hear the blackout you spoke of and you were able to restore the files, dangling commits or dangling objects , is the term in which the log is monstrated such as some tree file or object that has been corrupted and has been restored successfully. So in the log you see dangling commits or dangling objects .

21.07.2018 / 21:04