Oh they are soo nice to work with aren’t they? Until you realize that you accidentally uploaded one to your public repository. That’s what I accidentally did today. Fortunately, I caught it early on so that I didn’t have any issues with my database that I’m using.

Scene from Spaceballs the Movie, 1-2-3-4-5 amazing, I have the same combination on my luggage!

I have learned from this that I really need to think ahead with dealing with environment variables. Simply placing them in as an afterthought or during prototyping is not a great idea. Have the mindset from the beginning of your repo that you will probably need to use environment variables. Make an effort to ignore them up-front in your .gitignore file. That will save you some embarrassment later. However, if you do find yourself needing to quickly address this, here’s a git command that I found very useful:

git rm -f .env

Do this in addition to adding the file to your .gitignore file so that it ensures that it will never try to track the .env file. Hopefully, this gives you a great lesson on how to keep your variables private in the future.