If you lost all your references (refs folder), but don't lose any actual data you can find all possible last commits by finding dangling commits (i.e commits which are not referenced by other commits as parents)
You can do it with the help of this command
git fsck --lost-found
This lists all dangling commits (and probably some other useful information).
Use
git log SHA1SUM
to investigate further.
Also it is a good idea to run
git fsck
to make sure that only referenced where lost.
UPD: Also refs can be located in packed-refs file.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…