简体   繁体   中英

gitignore does not ignore files

在此输入图像描述 The image says it all. Why is git telling me that I've changed the file when I'm explicitly telling it to ignore it?

A .gitignore specifies files that should not be added to git 's index. It does not prevent changes to files that are already in the index.

If you want to remove the file completely from the index, you will need to commit a deletion of that file. Then if the file gets recreated (and it is still listed in .gitignore ), it will not be re-added to the index.

you have to remove it from the repository and then commit it.

git rm -rf --cached .idea/*
git add -A .
git commit -m "Removed idea files"
git push

And now all your .idea files will be ignored (if added to the .gitignore as described above).

You may have added the file previously, making it tracked. If it gets added to the .gitignore file after that, Git will still report changes to it because it is a tracked file.

You need to remove the file from the index and create a new commit.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM