I have a list of files that contain different configurations for live and development branches.
Currently, every time we need to test things we go and change all the configurations to dev settings, do our dev and then change them all back when it is time for the pull request. This is silly.
I'm looking for a git way to just exclude those files at merge time.
- I don't want to add them to the .gitignore, because that causes problems later on when someone else pulls the branch for example.
- Using environment variables won't work (or at least, to make it work would require lots of hacking and a heavy foot to stomp it into place)
- Our company is strict in that all merges from dev to live must go through a Pull Request. I think this is a good system.
- None of these look like a very good idea.
- This answer provides this solution (also this). However I've added all the config files to the
.gitattributes
file in both branches but a merge still overwrites them all.
So is there a git way into which I can paste a list of files that are branch specific and do not get merged during PRs?
EDIT
It seems worthwile to explain the system a bit.
We have 2 branches that always exist. master
for the live deployment environment and dev
for the development environment. These 2 branches should have identical code except for the configuration files. These files look the same, but they contain different IPs, VM names, paths etc.
If we develop a new feature, we would checkout from dev
, create that feature and test it in the dev environment, then once happy, create a PR and merge it into master. master
has to keep its own configs at this point. Same for master
and hotfixes, except that those changes would then get merged into dev
.
dev
never gets deleted, only the feature branches that work off dev do.
This is a big project with different config files that get sent all over the place for sub-modules. We can't just simplify and make one mega config file.