7
The scenario is as follows. I work on a project that contains a JSON file with database configuration. Something like:
{
"db_config":
{
"conn_string": "server:localhost;user:db-user;password=db-pass"
}
}
It turns out that I need to change these settings to run the project in my local environment, this because I use the remote database on a local server.
The problem is that whenever I change this file with my settings
I need to remember not to add it before the commit; or
I need to remember to change it before commit; or
I just committing the file and "spoiling" the configuration of all my project colleagues.
Put the file in the .gitignore would cause it to be deleted from the remote repository.
How can I ask GIT to ignore all the changes I make in this file? And how can I reverse this if I need to change some configuration in this file later?
What I usually do is commit the empty file and then put it in
.gitignore
. Then, in production, the variables are either placed inenv
or that file is overwritten on the server by another with the complete keys.– Sergio
I suggest working with profiles, one for dev and one for Prod. Each will have its configuration and will not need to change them anymore.
– Murillo Goulart
I appreciate the tips, but I just want a GIT command to stop "observing changes" in a given file. The scenario is fictitious =D
– Jéf Bueno
@jbueno understood your need, you just want to avoid modifications to a particular configuration file, but it needs to exist in advance anyway, see if this resolves http://stackoverflow.com/a/21756612/1518921
– Guilherme Nascimento