Skip to content

Instantly share code, notes, and snippets.

@omidkrad
Last active August 29, 2015 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omidkrad/70150317d91e84276c25 to your computer and use it in GitHub Desktop.
Save omidkrad/70150317d91e84276c25 to your computer and use it in GitHub Desktop.
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