8

I committed files from .idea folder, then I created .gitignore file, and I wanted to stop tracking those files from .idea folder. To do this, I wrote:

git rm -r --cached .

git add .

and committed changes. Everything was fine until Android Studio changed file misc.xml, by changing java language level, and I do not know why, but if I try to commit changes, I can still commit this file misc.xml, which is ignored and should not be tracking anymore. What can I do?

Android Studio View

Community
  • 1
  • 1
cerbin
  • 1,180
  • 15
  • 31
  • Did you do git add --all before commiting? – Darush Sep 18 '17 at 16:21
  • Maybe this answer can help you : https://stackoverflow.com/a/11451731/423980 – mt0s Sep 18 '17 at 16:22
  • @Darush yes, after I made this commend, I made a commit of these changes. – cerbin Sep 18 '17 at 16:25
  • @mt0s I made edit in the question, I used these commands to stop tracking ignored files, but one day after this, when Studio changed misc.xml, it still wants to add this to commit, even if it is no longer tracked. – cerbin Sep 18 '17 at 16:28
  • 1
    Hmm... What if you use this command : `git status --ignored` to check if the file is ignored so we can be 100% sure you have added it correctly in `.gitignore`? – mt0s Sep 18 '17 at 16:35
  • 1
    @mt0s That was it. This command did not show all files from .idea folder, only 2 of them, excluding "misc.xml". Then I did one more time commands "git rm -r --cached ." and "git add .", seems like previous command did not work or I broke something. – cerbin Sep 18 '17 at 17:08
  • I guess it was just too stupid or lazy... https://www.kernel.org/pub/software/scm/git/docs/ – ahasbini Sep 19 '17 at 22:11

1 Answers1

10

Thanks to @mt0s from comment, I executed command

git status --ignored

and it showed only two files from idea, excluding misc.xml:

.gitignore status

So I repeated the commands:

git rm -r --cached .
git add .

and now it works, it deleted all files from .idea from tracking, and now when I change something in a file misc.xml, it do not goes to commit. Result of repeated commands

cerbin
  • 1,180
  • 15
  • 31