The following monstrosity very nicely found a git stash containing the word Upload which is what I was looking for:
git fsck --no-reflog | awk '/dangling commit/ {print $3}' | \
while read ref; do if [ "`git show -p $ref|grep -c Upload`" -ne 0 ]; then echo $ref ; fi ; done
Is there a prettier version of this? I guess the pickaxe should work but git log -g
doesn't see this commit.
We can use the git reflog to recover a branch (of dangling commits) which was deleted without merging it. We can recover deleted commits only if it is present in local object store. If it was garbage collected, then we can't recover it.
Looking up changes for a specific commit If you have the hash for a commit, you can use the git show command to display the changes for that single commit. The output is identical to each individual commit when using git log -p .
Lucky for you, git has a 'grep' mode that's perfect for doing a git log search! and you'll see all of the log messages which contain the our search term!
On GitHub, you can see the commit history of a repository by: Navigating directly to the commits page of a repository. Clicking on a file, then clicking History, to get to the commit history for a specific file.
... but
git log -g
doesn't see this commit
Commits that are (still) referenced by the reflog are considered reachable and not dangling. Thus running git log –g
is contrary to what you wanted, so no surprises here.
Commits will be reachable via reflog for the gc.reflogExpire timespan, with a default of 90 days.
Is there a prettier version of this?
No, git fsck
is the right way for accessing dangling commits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With