1

I have a project with SETTINGS.ini config file which has sensitive information which I obviously don't want to include in GitHub repository. I know that .gitignore will not push it to remote repository, but I am wondering how can I replace SETTINGS.ini with some other SETTINGS.ini file without manually removing it in remote repository?

  • Note that what you know about `.gitignore` is wrong, in one important way: listing the file in `.gitignore` won't prevent pushing the file (as part of an existing commit) to another Git repository (`git push` pushes entire commits, so whatever files are in them, go along for the ride, every time). The point of listing a file in `.gitignore` is to be able to avoid *committing* the file, so that it's never actually in the repository proper, and therefore won't get copied when the repository gets copied. – torek May 29 '20 at 07:56
  • In other words: **if the file is already in a commit, watch out**. If it's not yet in any commit, you'll be OK. – torek May 29 '20 at 07:56

1 Answers1

2

Best practice would be to place SETTINGS.ini.sample (or similarly named) file in your repository, with some dummy values in it, and include instructions to copy that file as SETTINGS.ini with correct values for whoever is using it. Keep SETTINGS.ini in gitignore.

1615903
  • 32,635
  • 12
  • 70
  • 99