I published a VSCODE extension with the name
ignoreit. It automatically helps you to add files and folders to .gitignore and creates a symlink between ".env" and ".env.example" files. So, you’re sure your secrets are never pushed to github or other source controls.
- Install and navigate to
vscode settings.jsonand ensure you have "ignoreit.array": [".env", "node_modules", "coverage"] as one of the key-value pairs. The array is a list of files and folders you wish to always ignore. Feel free to modify it.
- If any of the files or folders specified in the array exists in your project directory, ignoreit extension will add it to the .gitignore file.
- If .gitigore file does not exist in your project directory, ignoreit extension will create a .gitignore file and fill in the files you're to ignore.
- The .gitignore content will be the files in your project directory that corresponds to the ignoreit.array
- You can manually add other files to the .gitignore file. New files are always appended to the existing ones.
- If .env file is part of the files in your directory, ignoreit extension will create a .env.example file and fill it with the the contents of your .env file. Only variables are filled in, values are left behind. The .env and .env.example files will always be in sync.
This extension works when you're working in a git repository on VSCODE.
This extension requires that ignoreit.array key be added to your VSCODE settings.json file and value should be an array of files you wish to automatically add to .gitignore file in all your project (if the files or folders exist in your project). See example below
"ignoreit.array": [".env", "node_modules", "coverage"]