Connect a keyboard and exit EmulationStation by pressing F4. From the command line, run
cd RetroPie-Setup sudo ./retropie_setup.shthe reset the inputs from:
Configuration/Tools ➤ emulationstation ➤ Clear / Reset EmulationStation Input Configuration
You can then start back EmulationStation by typing emulationstation and you should get prompted to configure your gamepad again.