.gitignore is added to the ignore rule. Why does it still prompt the version update? How does git clear the version management of some files?

Some files, such as the files in the /target/class directory after java compilation, *.iml files, etc., do not need to be uploaded to github. These files may change at any time, and it is meaningless to manage the version.
In the .gitignore file, rules can be set which files are not managed. However, if the version of the file has been managed before, no matter how to make rules, it is useless.
However, if you were not careful before and uploaded it, you need to remove it locally, then push the operation to github, and finally modify the rules of the .gitignore file.

Insert picture description here
As shown in the figure, if I don't want to manage .bat script files such as clean.bat, even if I add *.bat to .gitignore, after the bat script is modified, use git status to check the version status, and I will still see the update prompt of the corresponding file.

Insert picture description hereUse git rm -r --cached xxxto remove certain file version control
Insert picture description hereto use git commit -m " remove version control"to submit updates to the local database
Insert picture description here
using the git push origin mastercommand will update the local library gitee push to
Insert picture description hereupdate .gitignore documents in the rules, then no matter how you modify bat script will no longer prompt you to add submitted, and The color of the corresponding file has also changed from bright white to thin and short gray.
Insert picture description here
Summary of steps:

// -n:加上这个参数,执行命令时,是不会删除任何文件,而是展示此命令要删除的文件列表预览。
git rm -r -n --cached "clean.bat" 

// 执行移除命令. 
git rm -r --cached  "clean.bat"  

//提交    
git commit -m " remove version control"    

//提交到github或gitee等远程仓库
git push origin master   

Guess you like

Origin blog.csdn.net/qq_41885819/article/details/107492659