Question: how does damon come back to life in season 5?
Answer: After doing some magic under an eclipse, Bonnie sacrifices herself in order to push Damon into being into the real world in Season Six Episode Five. Thus, Damon is alive and well at the end of episode five and hugs Stefan.