3

My .gitignore:

.DS_Store
/.idea
/.idea_modules
/out
/project
/target
/*.iml
*/resolution-cache/*
*/streams/*
*/target/*

But nonetheless, the folders .idea, .idea_modules and target have appeared in a repo and are still there.

Your ideas?

Max
  • 21,123
  • 5
  • 49
  • 71
Alan Coromano
  • 24,958
  • 53
  • 135
  • 205
  • Possible duplicate of [.gitignore is not working](https://stackoverflow.com/questions/11451535/gitignore-is-not-working) – Giulio Caccin Nov 19 '18 at 16:30

1 Answers1

6

Ignoring is only useful for files that are not currently being tracked by the repo. If those directories were added to the repo before being put in .gitignore, they will continue to be tracked.

Use git rm --cached <file> to stop tracking a file.

Of course you should make a commit with the removed files and push to the repo to see the changes in the remote repository

Francisco Puga
  • 23,869
  • 5
  • 48
  • 64
Max
  • 21,123
  • 5
  • 49
  • 71
  • If I want to remove a whole folder, what's the format for that: `git rm --cached target` or `git rm --cached /target` or anything else? – Alan Coromano Jan 08 '14 at 02:15
  • To remove a whole folder, remove recursively `git rm --cached -r target`. – Max Jan 08 '14 at 03:16