5

I'm currently using BitBucket for my repos with the git engine. I'm not using github since is a private project, so I can't set it public.

When I create my .gitignore file with gitignore.io, trying to ignore PhpStorm and WebStorm, Gitkraken (which is my git client on Mac) it isn't ignoring the .idea folder. And each time I change my workspace layout opening or closing a sidebar or a file, then git is tracking that change. I can't figure out what's wrong, since I've also tried to set .idea/ in .gitignore, but the files inside it are still tracked...

Any ideas?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Caius
  • 2,084
  • 6
  • 31
  • 47
  • 1
    Has .idea already been tracked? If yes, .gitignore can not ignore it any more unless you remove it from git repo. – ElpieKay Jul 12 '16 at 09:25
  • http://stackoverflow.com/a/1274447/783119 ? – LazyOne Jul 12 '16 at 09:25
  • Thanks for the edit @LazyOne, and for the link to the question. I didn't knew that once a file is tracked it can't be ignore unless you remove it from the cache. Thank you all! – Caius Jul 12 '16 at 09:42
  • 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 Jul 12 '16 at 10:03

2 Answers2

19

update your .gitignore file. for instance, add one more folder for those you want to untrack in .gitignore: foldername.

To stop tracking a file you need to remove it from the index. This can be achieved with this command.

git rm --cached . remove all tracked files, including wanted and unwanted.

then

git add . all files will be added to track, exclude those in .gitignore.

Abdul Wahab
  • 740
  • 1
  • 7
  • 13
2

Solved

How @ElplieKay said, the file once is tracked it can't be ignored anymore. Unless you remove it from git.

Another solution is to remove the file or folder (using -r) from the shell. So on the next commit it will be ignored.

Community
  • 1
  • 1
Caius
  • 2,084
  • 6
  • 31
  • 47
  • 3
    You could ignore the files that already tracked by simply `git update-index –assume-unchanged /path/to/file`. – jayxhj Jul 13 '16 at 08:10