Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ignore dist folder in .gitignore file? [duplicate]

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?

like image 560
moses toh Avatar asked Jan 02 '20 10:01

moses toh


2 Answers

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

like image 166
Hurobaki Avatar answered Sep 22 '22 23:09

Hurobaki


Check the format

.DS_Store
node_modules
dist/
like image 36
Rebai Ahmed Avatar answered Sep 22 '22 23:09

Rebai Ahmed