0

I have a default config file in my git repo. I changed some of the configurations that's only meant for me. There's also a password field so I don't want to commit it. Without removing the file can I tell git to ignore the config file?

Eric Stotch
  • 141
  • 4
  • 19
  • Try this: https://stackoverflow.com/questions/1753070/how-do-i-configure-git-to-ignore-some-files-locally. -- run `git update-index --assume-unchanged ` – costaparas Dec 14 '20 at 07:02
  • Does this answer your question? [How do I make Git ignore file mode (chmod) changes?](https://stackoverflow.com/questions/1580596/how-do-i-make-git-ignore-file-mode-chmod-changes) – Anhdevit Dec 14 '20 at 07:03
  • 1
    https://stackoverflow.com/questions/3319479/can-i-git-commit-a-file-and-ignore-its-content-changes – kabanus Dec 14 '20 at 07:04
  • 1
    Does this answer your question? [How do I configure git to ignore some files locally?](https://stackoverflow.com/questions/1753070/how-do-i-configure-git-to-ignore-some-files-locally) – costaparas Dec 14 '20 at 07:04
  • 1
    Don't trust anyone who suggests to use `--assume-unchanged` for this purpose. Use `--skip-worktree` instead. [This is the correct answer.](https://stackoverflow.com/a/13631525/6868543) – j6t Dec 14 '20 at 07:14

2 Answers2

1

There is an answer here that might help you ignore specific lines.

That being said, a very common pattern is to have a tracked sample file that everyone copies to their own environment and add the actual settings file to gitignore.

For example you could have a .config.example file with just sample values and add that to your repo, and a .config with the sensitive values, that is private to you.

anpel
  • 931
  • 6
  • 16
0

Why don't you develop a configuration system similar to this:

env (default/global config file)

env.local (local config file included in .gitignore)

Where the parameters defined in env.local have priority over those defined in env.

However you can review this tutorial on how to ignore lines. Or this other question.

eniel.rod
  • 855
  • 8
  • 12