1

I have certain config files (in RoR stuff like: .env, config/database.yml, .ruby-version), and I want to customize them on my local environment.

I know how to ignore the file so they are not tracked locally, but how can I stop the file being synced with the origin after a "pull", or "merge"?

Peter R
  • 3,185
  • 23
  • 43
  • If a file is not tracked by git it will not do any modification to it. What probably happens to you is that the file was already checked-in before you added to gitignore. If this is the case look this question: http://stackoverflow.com/a/1330097/19046 – DaniCE Jul 08 '15 at 10:14

1 Answers1

1

I would recommend to version only template of those config files, instead of the actual config files with their valued.
You could consider a content filter driver (using .gitattributes declaration) in order to generate the actual files.

The idea is to manage those config files in version, but with template placeholders in place of the actual (sensitive) values.
The generated files remains ignored (by the .gitignore)

  • the smudge part could replace the template content with the actual value (on checkout)
  • the clean part could restore the template (on commit)

smudge

(image from "Customizing Git - Git Attributes", from "Pro Git book")

The main idea is: if values are depending on the environment, the smudge script would replace the placeholder values with actual values depending on the environment, values fetched possible from outside the repo (this is especially true for production values).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250