0

I would like to stop/prevent users to commit a file with sensitive data into a remote repository (GitHub). It is a C/C++ project, but the role of this file is like an .env file. My idea was to provide this file in an initial commit with the different available variables without any value assigned and allow the users to fill them with their personal/sensitive data and avoid its commit.

What I did was to add the file to the .gitignore and then to perform a git add -f of this file, but after that the file is tracked. And I don't want to remove it from the remote repo (git rm --cached), I just want to avoid them to commit changes on it.

To be clear, this project is for my students, so we can't expect to add files to the stage area individually (git add -A is the norm...) and git update-index --skip-worktree is not an option since is a client action (not like a .gitignore rule, which is pulled from the repo and is transparent for them).

Any idea?

Thank you very much in advance

Albert
  • 56
  • 7
  • Just a suggestion: put in the README the info for creating the `.env` file, add `.gitignore` and never commit the `.env` file – the_previ Sep 16 '21 at 20:43
  • If a file is in git it is being tracked. If you do not want it tracked, do not put it in git. Try creating a `.example` file which gets committed instead? – evolutionxbox Sep 16 '21 at 21:24

0 Answers0