Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Orphan Commits (wizardzines.com)
1 point by hasheddan on Jan 23, 2024 | hide | past | favorite | 1 comment


`git fsck --no-reflog` will show you orphan commits. Search for "dangling commit" in the output. It will take a while to run on larger repositories.

If you have gitk installed, this command will show a complete git tree, including dangling commits / branches:

gitk --all $( git fsck --no-reflog | awk '/dangling commit/ {print $3}' )

It may take a while to run.

A faster command is gitk --reflog which will use the reflog to find recent dangling commits. It's a great way to get a branch back if you have rebased or deleted it.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: