Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to stop tracking ignored file in Android Studio

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

like image 273
cerbin Avatar asked Sep 18 '17 16:09

cerbin


People also ask

How do I stop git from tracking and ignoring changes?

Use Git update-index to ignore changes To resume tracking, run the git update-index command with the --no-skip-worktree flag. Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.

How do I stop git tracking a file?

git rm --cached <path> … will cause git to stop tracking that path.

Does Gitignore ignore tracked files?

The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked. To stop tracking a file that is currently tracked, use git rm --cached.

Should Gitignore be tracked?

Yes, you can track the . gitignore file, but you do not have to. The main reason of having this file into repository is to have everyone working on the project, ignoring same files and folders. Also see this: Should you commit .


1 Answers

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

like image 156
cerbin Avatar answered Sep 28 '22 06:09

cerbin