简体   繁体   中英

Git best practice - adding a placeholder config file

I have a repo that is cloned to various machines, that all require a config file which is not identical for each, and I'd rather not have their content visible in the history of the repo. The machines are pull-only.

What is the best practice to have a placeholder config file in the repo, that I can change for each machine? While I see that this problem could be solved by pushing the placeholder config and then never changing it, I believe there must be some better way to prevent merge conflicts. I tried pushing a config file and then adding it to .gitignore , but I've since come to understand that that does not work for files that are already tracked.

Is there some way to make git stop tracking updates to a file, while still having the file available in the repo when cloning it? If not, what is the best practice to achieve my goal?

Maybe something like this?

  • Create all config files (eg configMachine1.xml, configMachine2.xml...)
  • Ignore finally used config file eg config.xml (gitignore)
  • Create a script loadConfig.sh (this script just do a copy from configMachineX.xml to config.xml. Maybe you could identify the running machine automatically here, so you do not need to specify the configuration filename each time)

This should be really easy to use + you are able to versioncontrol all configuration file of all machines.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM