I was working on a Angular-Firebase project. I had stored the firebase configuration in a config file. I wanted git to recognize and index the initial version of the file with keys listed in it but not values. Which implies that I had to commit the initial version of the file but force git to ignore any future modifications.
The solution that I came across at stackoverflow servered my purpose.
Step 1: Create the config file. Lets call it,
firebase.config.ts (I use TypeScript). And commit it.
$ git add firebase.config.ts $ git commit -m "Default version of the firebase configuration." firebase.config.ts
Step 2: Inform git to skip tracking the changes in the file.
$ git update-index --skip-worktree firebase.config.ts # Check if the file is marked to be ignored $ git ls-files -v . | grep ^S # To enable tracking changes in the file, use the below command: $ git update-index --no-skip-worktree firebase.config.ts
Refer the Git update manual for additional details about the options.