Think of the number of people who use git, each has to individually configure the same exact thing for every machine they use git on.
ALL of that could be solved with extending the pre-existing convention of ignoring the .git directory to have a second directory to stash stuff that you need but should not be in git.
Then the gitignore becomes something related entirely to code, right now it includes all sorts of stuff depending on what idea are used or build system or whatnot
Desktop.ini is also implicitly ignored on windows, .DS_Store isn't on macOS though unfortunately
Eh, I feel like such a folder makes sense to explicitly define in a .gitignore if it'll have the same name, in my case it's usually a lone file in a weird place
Could you guys *please* stop putting credential files in your project directory? These files should never be there in the first place. `.gitignore` is for build artefacts, not for files that would ruin your life if exposed.
I'm new to this level of programming and just learned about .env and thought the gitignore was right. But, your comment has me curious...could you please point me in the right direction of what a better method is for storing credentials and these other type of files? Should I have some sorta postgre database, or something?
Well the most important thing is to not have any files containing sensitive data of any form in your project directory. So using dotenv is fine but but don't keep the .env file in your project directory. Instead make sure your application is started with an env var DOTENV_CONFIG_PATH poiting to a directory somewhere safe in your workspace where you locally keep sensitive files. Arguably, when you already have to configure an environment variables to be set at startup you could also use a runconfig as supported by all IDEs where you can either set that DOTENV_CONFIG_PATH or just set all the variables directly there. Now all of this is only to ensure you keep your data stored locally. Depending on how sensitive that data is you might have to take further precautions to prevent your data to be stolen from your local filesystem using some kind of vault system.
Stage files in vscode, it's much easier/precise than doing it in the terminal. (I say this as someone who regularly scripts and writes custom zsh aliases.)
Not sure how you stage files in VS Code (only using Git in the terminal myself), but you can stage changes hunk-by-hunk in the terminal by using git add -p
Since when is everybody being schizophrenic about env files? Did some influencer get sponsored by a key vault SAAS and now everyone parrots them or is there an actual reasoning beyond "oh no malware scans for env files"
The humble pass is local to the machine and free. Combine with direnv and your "ENV" variables are only loaded in the appropriate directories.
Of course, the trade off is a little hit on speed (GPG decrypt).
No need for SaaS. But even if one wants a centralized vault - OpenBao is basically HashiCorp Vault, but free and managed by Linux Foundation. Deploy it on a NAS if you have one and you're set.
Please don't put secrets in your .env. That's how they leak if you get compromised.
They should be pulled from a store and kept at runtime.
Edit: Even locally. This is how NPM supply chain attacks are breaching thousands of companies these days. The first thing they do is look for .env files and send any values back to their creator. If you have things like AI inference keys in there you're getting pwned
.env files are usually for development on your local machine, for actual deployment you have environment secrets set by the orchestrator, CICD pipeline or whatever else is responsible for getting your service up and running
If someone can compromise your env on prod they will be able to freely read your in memory keystore as well
They search for ssh keys and npmrc files too. What store am I supposed to connect to and how am I supposed to connect to it every time I want to start my vite server?
You still need real keys for local development for things like external integrations and AI inference integrations and a lot of providers don't let you scope them securely
Downvoting me is fine but literally thousands of orgs are falling to supply chain attacks these days, it's ignorant to store any keys on your filesystem. It's your problem if it happens to you.
Ye I don't understand the downvotes either. Could be some provider didn't update their standards, but nowadays the one I use provide different keys with different access rights.
But yes there can be useful data for attackers even in dev databases and services.
13
u/pickle9977 Oct 17 '26
Git should have like a default git ignore that will by default never commit something like a directory named .private just as a convention
62
u/pandi85 Oct 17 '26
Hey claude why did you rename this .env to prod-teste2e2creds and committed it. Oh good catch, i shouldn't have done that.
289
u/SaneLad Oct 17 '26
Could you guys *please* stop putting credential files in your project directory? These files should never be there in the first place. `.gitignore` is for build artefacts, not for files that would ruin your life if exposed.
85
u/nicuramar Oct 17 '26
And/or don’t just add all files. I always add them as needed, and then use git add --update (aliased to gau) from then on.
12
u/Big_Action2476 Oct 18 '26
Jokes on you, my company commits secrets to the repo in plain text
12
u/riickdiickulous Oct 17 '26
Run a gitleaks scan as a pre-commit hook, in addition to .gitignore
8
u/Tolik1111 Oct 17 '26
SOPS, ever heard of him
4
u/ExtraTNT Oct 18 '26
The funny test scripts, the test data, the scratchpad with random notes, 200Gb of libs…
5
u/susparab44 Oct 17 '26
Check your staged files before committing..🫡
1
u/happychloroplast Oct 17 '26
y'all, openbao is free...
4
u/Bulky-Ad7996 Oct 17 '26
All jokes aside, I love that artwork.
1
u/Turbulent_Ebb_9741 Oct 17 '26
Guys don't ignore gitignore
1
u/Killfile Oct 18 '26
Use exclude rather than ignore. Thst way you don't leave fingerprints of all the crap you didn't want to include.
1
u/imnotcook Oct 18 '26
.gitignore doing the Lord’s work every single day. Still wild how many people learn this the hard way
1
u/NoahZhyte Oct 17 '26
Why do you have all those on your computer at all ???
0
u/throwawaygoawaynz Oct 18 '26
GitHub hasn’t let you push secrets for ages now.
-4
u/PhatOofxD Oct 17 '26 edited Oct 18 '26
Please don't put secrets in your .env. That's how they leak if you get compromised.
They should be pulled from a store and kept at runtime.
Edit: Even locally. This is how NPM supply chain attacks are breaching thousands of companies these days. The first thing they do is look for .env files and send any values back to their creator. If you have things like AI inference keys in there you're getting pwned