How to skip tracking changes in a file while using git?

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.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s