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.
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.
Use git rm -r --cached xxx
to remove certain file version control
to use git commit -m " remove version control"
to submit updates to the local database
using the git push origin master
command will update the local library gitee push to
update .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.
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