The short answer is, “yes”. You should use your .gitignore file to ignore the .env file.
In most operating systems by default, files that start with a period (.) are hidden. When setting up my .gitignore file, I like to ignore all these hidden files (with a few exceptions).
This is my general starter .gitignore file for projects. I have a separate .gitignore for WordPress websites.
I’m a big fan of Git and I’ve worked with lost of developers in growing their Git skills. Often developers learning Git, start by learning how to write a “good” commit message. While writing “good” commit messages is an important skill, in my opinion it is the wrong place to start.
These are the rules I follow when writing Git commit messages. I’ve found these serve me well and are compatible with most projects I work on (if a project has a specific set of rules for writing Git commit messages, those would override any rules I’ve outlined here).
One of the things that made me much better at Git was making my current branch (and whether or not I have any changed files) always visible. By default zsh includes everything you need to do this, you just need to configure it.
When using Git version 2.27.0 or higher running the command ‘git pull’ will display, “warning: Pulling without specifying how to reconcile divergent branches is discouraged. You can squelch this message by running one of the following commands sometime before your next pull”.
When using a WordPress translation function, e.g. __(), you need to use a hardcoded string (not a variable).
Lately I’ve been joining Zoom meetings with lots of new users and I find I keep sharing the same tips. The short version is: use Gallery View, Mute Yourself, and take advantage of Chat.
You can set Git to preview all of the changes in your commit when you write your commit message. I find this to be a big help in writing my commits (and reminds me to keep the changes in my commits small).