Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.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?

like image 300
Caius Avatar asked Nov 30 '22 23:11

Caius


2 Answers

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.

like image 117
Abdul Wahab Avatar answered Dec 18 '22 19:12

Abdul Wahab


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.

like image 23
Caius Avatar answered Dec 18 '22 19:12

Caius