gitignore file invalid

How to deal with the invalidation of gitignore files
Here we need to analyze the invalidation situation:
1. The file has been added to the temporary storage area, and then the filtering restrictions are added in gitignore
as shown in the figure: At this time, the .gitignore file is configured, but the .idea file The folder is still green (that is, it has been added to the git temporary storage area)
insert image description here

Steps to be performed at this time:
1. Remove all current files in the git temporary storage area, that is, the tracked files
Open gitbash in the root directory of git, and all subsequent operations are in the root directory

git rm -r --cached .

insert image description here

2. Check whether all have been removed successfully

git ls-files

insert image description here
insert image description here

3. Re-add the project folder to the git temporary storage area
At this point, the added file will go to gitignore again, and confirm whether it is filtered at this time

git add .

View the effect, as follows
insert image description here
insert image description here
So far, gitignore is back in effect

Guess you like

Origin blog.csdn.net/lzq2357639195/article/details/129707108