Skip to content

Instantly share code, notes, and snippets.

@omidkrad
Last active August 29, 2015 14:20
Embed
What would you like to do?
Git Tips

Git Tips

Reviving a discarded commit

You created a commit but then discarded it with git reset --hard <SHA> without first syncing it with the server repository (GitHub). Use this PowerShell command to find the SHA of the discarded commit.

Get-ChildItem -Path .\.git\objects\??\* -Recurse | sort -Property CreationTime -Descending | select -first 1 | % { $_.FullName.Substring($_.FullName.Length-41).Replace('\', '') }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment