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?
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.
git rm --cached <path> … will cause git to stop tracking that path.
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.
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 .
Thanks to @mt0s from comment, I executed command
git status --ignored
and it showed only two files from idea, excluding misc.xml:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With