Does .gitignore just not work?

I added the env file to my .gitignore and it literally does nothing, vscode still keeps trying to stage it and it can still be commited
Solution:
If it was included in a previous commit, you must remove it from the index, this should do the trick: git rm --cached <file>. More info at https://stackoverflow.com/questions/1274057/how-do-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore
Jump to solution
3 Replies
BossDaily
BossDaily14mo ago
# Ignore a blackhole and the folder for development
node_modules/
.vs/
.idea/
*.iml

# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml

# Environment variables
.DS_Store

dist/

# Ignore the config file (contains sensitive information such as tokens)
config.ts

# Ignore heapsnapshot and log files
*.heapsnapshot
*.log

# Ignore npm lockfiles file
package-lock.json

# Environment variables
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
*.env
src/.env
# Ignore a blackhole and the folder for development
node_modules/
.vs/
.idea/
*.iml

# Yarn files
.yarn/install-state.gz
.yarn/build-state.yml

# Environment variables
.DS_Store

dist/

# Ignore the config file (contains sensitive information such as tokens)
config.ts

# Ignore heapsnapshot and log files
*.heapsnapshot
*.log

# Ignore npm lockfiles file
package-lock.json

# Environment variables
.env.local
.env.development.local
.env.test.local
.env.production.local
.env
*.env
src/.env
the env file is in the src folder
Solution
kyra
kyra14mo ago
If it was included in a previous commit, you must remove it from the index, this should do the trick: git rm --cached <file>. More info at https://stackoverflow.com/questions/1274057/how-do-i-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore
BossDaily
BossDaily14mo ago
ight that worked thx