0

I have file named config.xml. I added .gitignore and within it I put config.xml. I do git rm --cached config.xml and commit my changes. In the future my changes on config.xml in my local won't effect anything. But that's not what I want.

I want 2 version of config.xml. On my remote branch I will use production code and in my local I want to have localhost configuration. How to do that? I'm lost..

Thian Kian Phin
  • 921
  • 3
  • 13
  • 25
  • Try to not put config into version control.. It's bad for many scenario. – weigreen Jun 04 '16 at 12:16
  • That's not how you do this. Git is designed to synchronise across multiple locations, not have different versions in different places. – jonrsharpe Jun 04 '16 at 12:18
  • @weigreen I use git to deploy stuff, if not where else I should put it? it's a part of the application. – Thian Kian Phin Jun 04 '16 at 13:44
  • Possible duplicate of [Ignore files that have already been committed to a Git repository](http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – Edward Thomson Jun 04 '16 at 16:56

1 Answers1

1

with git

you can use a post-merge git hook to replace the content of the config.xml file with the content of your local file that you can rename config.local.xml

without git

you can have two configs files : config.dev.xml and config.prod.xml. The way to use the right files at the right place depend on the framework you use.

teriiehina
  • 4,741
  • 3
  • 41
  • 63
  • I use node.js with express. How can I know it's on localhost or in server? I don't think it's possible because it's an API. – Thian Kian Phin Jun 04 '16 at 13:22
  • you can have a look at [this answer](http://stackoverflow.com/a/8563528/700317), linking to [nconf](https://github.com/indexzero/nconf). Also, sometimes, it's good to "lose" some time to read the documentation ;) – teriiehina Jun 04 '16 at 19:14