Excluding Environment Files from Github Angular 4 Project Excluding Environment Files from Github Angular 4 Project angular angular

Excluding Environment Files from Github Angular 4 Project


To quote the Git website:

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.

In other words, gitignore won't remove files that are already in your repository, it'll just stop them being added in the first place. So if you've already accidentally commited your environment files, adding them to gitignore isn't enough; you'll also need to untrack the files.

The documentation goes on to say how to fix it:

To stop tracking a file that is currently tracked, use git rm --cached.

Note that this won't remove the file from your commit history, however - if you've accidentally leaked any sensitive info, see the GitHub documentation for info on what to do.