Like most image editing tools, Gimp, give you the opportunity to Undo/Redo (CTRL+Z/CTRL +Y) changes performed while working on a particular image.
But as you may have noticed the number of undo levels is not infinite.
To set the number of undo levels:
Click on Edit> Preferences
Select the "Environment tab"
In the "Resource Consumption" section, change the value next to:
Minimal Number of Undo levels
Maximum Undo memory
It is important as Gimp will require a larger cache to allow you to make use of a greater number of undo levels.