VS2019 添加.gitignore不生效问题
  m33FiQF5dk1h 2023年11月13日 23 0

步骤一:Git 的数据库中删除对于该文件的追踪     【 git rm -r --cached .】

步骤二:对应的规则写入.gitignore,让忽略真正生效   【 git add . 】

步骤三:提交+推送  【git commit -m "update .gitignore"】


1:$ git rm -r --cached .

rm '.gitattributes'

rm '.gitignore'

rm 'GameBiz.AutoRunner.Test/App.config'

rm 'GameBiz.AutoRunner.Test/GameBiz.AutoRunner.Test.csproj'

rm 'GameBiz.AutoRunner.Test/Properties/AssemblyInfo.cs'

rm 'GameBiz.AutoRunner.Test/UnitTest1.cs'

rm 'GameBiz.AutoRunner.sln'

rm 'GameBiz.AutoRunner.vsmdi'

2:$ git add .

3:$ git commit -m "update .gitignore"

[VN 14d740e] update .gitignore

11 files changed, 63 deletions(-)

delete mode 100644 Outputs/Common.Lottery.dll

delete mode 100644 Outputs/Common.dll

delete mode 100644 Outputs/External.Client.dll

delete mode 100644 Outputs/External.Core.dll

delete mode 100644 Outputs/GameBiz.AutoRunner.dll

delete mode 100644 Outputs/GameBiz.Client.dll

delete mode 100644 Outputs/GameBiz.Core.dll

delete mode 100644 Outputs/WinServices.Services.exe

delete mode 100644 Outputs/WinServices.Services.exe.config

delete mode 100644 Outputs/WinServices.Setup.exe

delete mode 100644 Outputs/install.bat


原因是: 当 .gitignore 文件配置好后,往往不能失效。这是因为 .gitignore 只能忽略那些没有被追踪(track)的文件,因为 git 存在本地缓存,如果文件已经纳入了版本管理,那么修改 .gitignore 是不能失效的。那么解决方案就是要将 git 的本地缓存删除,然后重新提交。

参考地址:https://cloud.tencent.com/developer/article/2217197

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月13日 0

暂无评论

推荐阅读
  KRsXEGSB49bk   2023年11月22日   23   0   0 本地缓存git取代码