Maintain multiple git branches for same ionic project

This is regarding the maintenance of two or more branches of ionic project.
E.g: dev, stage, prod.

These three branches are having different configurations and firebase settings.
The problem arises when going to make a modification. Once the modification is done to dev branch and try merge it to stage branch it merges with all configurations and settings.

Otherwise I have to do the same modification for all three branches separately.
How to overcome this problem and has anyone else faced this issue?

you would need to remove the node modules, platforms, plugins folders and package-lock.json file. and run npm i each time you switch to a different branch.