Tagged: dangling-commit

Your branch is ahead of 'origin/master' by 3 commits or dangling commits

- by admin

Once upon a time, namely today, I run
# git status

and to my big surprise I have got:
# On branch master
# Your branch is ahead of 'origin/master' by 3 commits.
#
nothing to commit (working directory clean)

Actually I have not done any commits in this local master branch - only pulls from remote. So, next I did
git fsck --no-reflogs

which helped me to get so called ‘dangling commits’ - commits that are under no particular branch:
git fsck --no-reflogs
dangling commit be6b64ba93d9e292b2aeec0a9d3c5209ee83c96f
dangling commit 3229271230d1315924ddd99c5962247d3c3f103b
dangling commit 95c0a7b1611ad0c4c101ff1fa1504d622fa1d2c3

What is exactly in the dangling commit? To get it I run:
git show be6b64ba93d9e292b2aeec0a9d3c5209ee83c96f

Next question: how to delete these dangling commits?

The answer is: wait :-)

Once your reflog entries are expired, those objects will then also be cleaned up by
git gc

Expiry settings are in gc.pruneexpire, gc.reflogexpire and gc.reflogexpireunreachable.

« All tags