0

I have a .gitignore file like this:

./dist/

However when I get the unstaged changes

$ git status

the dist directory is still shown as changed. What am I doing wrong?

dopatraman
  • 13,416
  • 29
  • 90
  • 154
  • 2
    Were the `dist` files already committed to the repo? – Karin Aug 12 '16 at 02:29
  • You need to `git -rm` the files first, if they are already part of the repository. – Tim Biegeleisen Aug 12 '16 at 02:33
  • No, the files were not already committed – dopatraman Aug 12 '16 at 02:43
  • Possible duplicate of [Ignore files that have already been committed to a Git repository](http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository) – 1615903 Aug 12 '16 at 04:50
  • @dopatraman if `git status` shows them as _changed_, that means they are already added and committed to the repository. New files are listed as _untracked_. – 1615903 Aug 12 '16 at 04:52
  • Also, there's no need for `./` at the beginning of the .gitignore line, just use `dist/` – 1615903 Aug 12 '16 at 04:53
  • @dopatraman Are you absolutely sure that the dir does not contain committed files? Try doing `git log -- dist`. Does that give any output? – Alderath Aug 12 '16 at 08:45

3 Answers3

0

Solution 1:

Try this (backup your ./dist/ directory before proceeding):

git rm --cached

The above command will remove ignored files, so you can expect your "./dist/" directory to be removed. From the next time you change anything inside this directory will be ignored.

Solution 2:

Remove "./dist/" directory manually and commit. If you create the same directory once again it will be automatically ignored.

If nothing works, check your .gitignore file.

Srujan Reddy
  • 730
  • 1
  • 6
  • 27
-1

If the files were already committed, you need to clear the cache. Please follow this answer.

Community
  • 1
  • 1
Alexis Côté
  • 3,670
  • 2
  • 14
  • 30
-1

Use git rm command to achieve it.

 git rm -r --cached your-ignore-folder-name