Skip to content

Instantly share code, notes, and snippets.

@npasserini
Created September 22, 2018 12:28
Show Gist options
  • Select an option

  • Save npasserini/5646b4c93221c07c53a1c6e362b48c42 to your computer and use it in GitHub Desktop.

Select an option

Save npasserini/5646b4c93221c07c53a1c6e362b48c42 to your computer and use it in GitHub Desktop.
List dangling commits
#!/bin/bash
PAGER= \
&& git fsck --full --no-reflogs --unreachable --lost-found \
| grep commit \
| awk '{print $3}' \
| xargs -n 1 git log -n 1 --pretty=oneline
@npasserini

Copy link
Copy Markdown
Author

This script allows to find a commit that is not referenced by any branch. It is useful in case you accidentally delete a branch that had not been pushed to any remote.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment