.gitignore 无法工作

在开发一个新项目时,发现每次编译时都会产生一些 .obj 无用的文件,这些文件并不需要 push 到 github 上

故使用 .gitignore 忽略这些文件

首先,我们可以设置这些文件的输出目录,比如建一个 temp 的中间目录

然后在本地新建一个 .gitignore 文件

在其中写入 temp .vs 忽略文件夹项即可,再重新编译时就会发现 vs code 忽略了这些文件的修改


如果发现添加 .gitignore 文件后,不起作用,可以参考:Gitignore not working

输入三行命令:

git rm -r --cached .
git add .
git commit -m 'Remove ignored files'

 

posted @ 2022-10-11 11:46  strive-sun  阅读(31)  评论(0编辑  收藏  举报