Populations exposed to changing environments must adapt to persist. Here we ask which factors determine a population's ability to persist in changing environments through genetic adaptation. We investigate the adaptive response to both a gradual, directional change in the environment and a sudden, sustained shift. Throughout, we use the canonical equation of adaptive dynamics, which allows us to derive analytical expressions while including ecological processes neglected in previous theory.