IntelliJ has a feature called "Local History" which stores basically is storing undo history, but it stores other things too (like test execution).
https://www.jetbrains.com/help/idea/local-history.html