I use the "undo" functionality in my editor. In emacs it's a complete tree of changes so you can't really lose anything.
But thanks for the tip about Emacs undo tree, didn't know about that. With some add-ons you can apparently eg find undoable changes for only some region of a buffer, etc.
This is built into Emacs (no add-ons needed). Calling undo with a region selected undoes changes only in that region.