Modify the boot sequence to prevent the switch from using the factory default settings or, conversely, to prevent loading a saved configuration file.
enable
configure terminal
Bypass the loading of the switch configuration file and load the factory defaults:
boot config flags factorydefaults [config-only | reset-all-files | zero-touch | zero-touch-config-only]
Use a configuration file and not the factory defaults:
no boot config flags factorydefaults

Important
If the switch fails to read and load a saved configuration file after it starts, check the log file to see if the log file indicates that the factorydefaults setting was enabled, before you investigate other options.
Modifying the boot sequence with an optional behavior of the factory default boot flag.
Switch:1>enable
Switch:1#configure terminal
Switch:1(config)#boot config flags factorydefaults
Switch:1(config)#boot config flags factorydefaults config-only
Warning: If you try to reset with a new image, it will not be loaded.
To undo this operation use "no boot config flags factorydefaults"