Look at techniques such as Dependency Injection, and Feature Flags. Each deployment should only be a different configuration of Feature Flags. Otherwise, you're overcomplicating things.
Managing feature flags are not always easy, but creates significantly less maintenance overhead than managing multiple mostly similar, but different codebases.