The undo operation can be applied almost to anything in GIMP. You can access it by clicking Edit | Undo, or by it's hotkey Ctrl + Z. If you want to restore the last operation after undoing it, just hit Ctrl + Y or Edit | Redo to redo it. There is a way to keep track of what were the last operations applied to an image. Just look at the Undo History dialog. Keep in mind that this history is not saved when you save your image to disk. The length of the Undo History can be changed inside the Edit | Preferences | Environment window:
Check the Minimal number of undo levels and the Maximum undo memory options. The first one sets how many undo levels GIMP will maintain, regardless of how much memory they consume. The second option sets the maximum amount of memory GIMP will use for the undo before it starts deleting the oldest undo operations.
There are a few things that cannot be undone:
Closing the image.
Reloading the image from the file.
Complex manipulations. For example, working with the Intelligent Scissors tool means you have to create a path and create a selection. Clicking undo will not get you back to the path creation, only to the starting point.
Filters and plugins can be undone, but that depends on how each operation they perform is implemented. If it's not, that can corrupt your undo history, deleting not only the last but all the history. That can also happen if you cancel a plugin/filter operation before it's done. The filters and plugins that come with GIMP are fully tested, but you should check the documentation of any filter or plugin you get from anywhere else to avoid running into any kind of problem while working.