0

I am current running a number of repositories for my companies application.

We have two repositories that require settings files for their builds to function. These settings files are different depending on local, dev, staging and production builds.

Each project has a development, staging and production branch.

I have add a .gitattributes file with the following contents:

gomo-campaign-api/src/main/webapp/WEB-INF/database.properties.xxx  merge=ours
gomo-campaign-api/src/main/webapp/WEB-INF/gomo-messenger-config.xml.xxx merge=ours
gomo-campaign-api/src/main/webapp/WEB-INF/hibernate.cfg.xml.xxx merge=ours
gomo-campaign-api/src/main/webapp/WEB-INF/legacy-session-mapping.properties.xxx merge=ours
gomo-campaign-api/src/main/webapp/WEB-INF/log4j.properties.xxx merge=ours
gomo-campaign-api/src/main/webapp/WEB-INF/messengerPublisher.properties.xxx merge=ours

I also have an sh file I run with the following contents:

git update-index --assume-unchanged gomo-campaign-api/src/main/config/messengerPublisher.properties.xxx
ECHO ignoring log4j.properties.xxx
git update-index --assume-unchanged gomo-campaign-api/src/main/config/log4j.properties.xxx
ECHO ignoring legacy-session-mapping.properties.xxx
git update-index --assume-unchanged gomo-campaign-api/src/main/config/legacy-session-mapping.properties.xxx
ECHO ignoring hibernate.cfg.xml.xxx
git update-index --assume-unchanged gomo-campaign-api/src/main/config/hibernate.cfg.xml.xxx
ECHO ignoring gomo-messenger-config.xml.xxx
git update-index --assume-unchanged gomo-campaign-api/src/main/config/gomo-messenger-config.xml.xxx
ECHO ignoring database.properties.xxx
git update-index --assume-unchanged gomo-campaign-api/src/main/config/database.properties.xxx
ECHO Initialisation completed.

Neither of these strategies seem to work, if I do an auto merge, i.e

git checkout staging
git merge development

If anything has changed in any of those files, it is still trying to move the changes over.

Have I missed anything in the config for these strategies?

There is only me and one other user who will ever perform a dev > staging or staging > prod merge (or even has access to do so) Other users, must create pull requests to get their branches into development. So I can easily stop other users making the changes to the dev file and introducing local configs.

However, I really need to the merge to ignore these files on merges.

If I was to checkout staging and make a change and push it in to the repo, I want that change but do not want it to be moved to production.

I hope I have explained myself with enough detail.

Thanks in advance.

Jamie Reid
  • 532
  • 2
  • 17
  • 1
    The short answer is that you can't. (You can in *theory;* see http://stackoverflow.com/a/41825703/1256452 - you may also want to read http://stackoverflow.com/a/42104116/1256452 - but that requires writing nontrivial code.) That's why it's always a bad idea to version-control configuration files. Instead, version-control *sample* or *default* configuration files, and keep the *actual* configuration out of the grubby paws of your version-control software. (Or, if you do version-control it, do so in an *independent repository*, not part of the software itself.) – torek Feb 23 '17 at 16:28

1 Answers1

0

One of the solutions we considered was keeping them in a separate repository but the solution we have gone with is using the profile tag in maven and creating settings files for each environment in the repo

Not the most graceful of solutions but a solution nonetheless.

Jamie Reid
  • 532
  • 2
  • 17