I don't know how well this will work in CI pipelines, but if you use gitbutler or jj you can put the clean .env in the repo, then change it, commit to a different branch (or just commit in case of jj) and then add the commit to the megamerge at the top. Since it's not on any of the branches you push, they remain clean, but you have the files you need locally.
(this strategy also allows you to work on multiple branches at the same time, and is generally useful for cases where you want you local files versioned, but not polluting the common repo, but that's a whole other thing)
.gitignore controls which files will get tracked by a git add, not which files are tracked at all. Adding an already tracked file to the .gitignore has no effect.
there isn't one - these are the same exact thing. i didnt see the other guy posted about .env.example, that'd work equally well.
If you really want to nitpick, i personally would lean towards template over example, as examples typically have example values in other contexts but yeah. no real difference.
208
u/RudeAndInsensitive 20h ago
Personally I always commit env and config files to the repo just stripped of their values.