1

I have a git repo for a project and I want to use git for updating the files on the server (Sometimes I forgot to copy all the updated files after working on something for days).

with "pull" I can be sure that all the updated files will be downloaded into the server. But this also has a downside.

The connection string is different between production and live versions, so the web.config file on the server should not be updated while pulling the changes.

I tried gitignore but looks like it works only with commit. How can I keep the web.config on the server as it is?

My repo is on github, the server is windows2008 and I use git extensions.

Thanks

dvdmn
  • 6,456
  • 7
  • 44
  • 52
  • 1
    Have you considered not checking in the config file into version control, but manually putting it on the server? – TimWolla Feb 22 '14 at 02:37
  • 1
    configurations that are machine specific should not be in source control and pushed around. Configurations that affect code behavior is fine. Connection strings to sql are machine/env specific - get it out of the web.config since you want the web.config for other code specific settings – bryanmac Feb 22 '14 at 02:46
  • 1
    What @TimWolla said. If not that, either [content filters](http://stackoverflow.com/q/15150317/1290731) or [branch-specific includes](http://stackoverflow.com/q/20078756/1290731) will do ya. – jthill Feb 22 '14 at 02:47
  • The answer was much simple than I thought, thanks guys. – dvdmn Feb 22 '14 at 02:59
  • @dvdnhm I compiled the comments into an answer and added some additional information as well. – TimWolla Feb 22 '14 at 03:09

1 Answers1

1

You should not check in environment specific configuration files into version control, but manually put them on the server. This approach has got the following advantages:

  • Less hassle when deploying the application into different environments (Development, Testing, Production)
  • Better security of sensitive data. Probably any developer has got access to version control, but maybe they should not have access to sensitive data like passwords. A commit introducing a change to fetch the passwords is detectable and will be detected, simply logging into the database probably won't.
  • Also it is much harder for malicious software to obtain these information, as it needs to get on the server instead of one of the developers machines
TimWolla
  • 31,849
  • 8
  • 63
  • 96