Caius
Caius

Reputation: 2264

.gitignore isn't ignoring my files

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?

Upvotes: 6

Views: 6283

Answers (2)

Abdul Wahab
Abdul Wahab

Reputation: 750

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 the below command.

Remove all tracked files, including wanted and unwanted:

git rm --cached .

then

All files will be added to track, excluding those in .gitignore:

git add .

Upvotes: 20

Caius
Caius

Reputation: 2264

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.

Upvotes: 3

Related Questions