17

I want to ignore the dist folder. So when there is a change in the dist folder, it doesn't appear in the commit

In the .gitignore file, there had exist /dist like this :

.DS_Store
node_modules
/dist

But why when there are changes it still appears?

How can I solve this problem?

moses toh
  • 12,344
  • 71
  • 243
  • 443

2 Answers2

56

With Git if you commit a file or folder, Git will continue to track it even if you put it inside your .gitignore. Because .gitignore just prevent untracked files from being added.

To stop tracking you have to remove it from Git index

git rm -r --cached <folder> // git rm -r --cached dist

It will keep the folder on your local but it will not being tracked anymore.

For folder in .gitignore the correct format is dist/ with trailing slash

1615903
  • 32,635
  • 12
  • 70
  • 99
Hurobaki
  • 3,728
  • 6
  • 24
  • 41
  • Is there any way for it to persist? I have to do it literally every time I make a new build – Jojko Jul 19 '23 at 10:27
8

Check the format

.DS_Store
node_modules
dist/
notapatch
  • 6,569
  • 6
  • 41
  • 45
Rebai Ahmed
  • 1,509
  • 1
  • 14
  • 21