github ignore设置无效的解决方式

stackoverflow答案

Even if you haven't tracked the files so far, git seems to be able to "know" about them even after you add them to .gitignore.
NOTE : First commit your current changes, or you will lose them.
Then run the following commands from the top folder of your git repo:

git rm -r --cached .
git add .
git commit -m "fixed untracked files"

也可以做成脚本,在项目根目录下执行。(记得先把本地代码提交)

#!/bin/sh

git rm -r --cached .
git add .
git commit -m "fixed untracked files"
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,136评论 0 10
  • 因为原文太长超出字数,Lesson 3 就放在另一篇文章里 How to Use Git and GitHub 标...
    赤乐君阅读 10,674评论 1 5
  • 昨天是中秋节,我们吃了许多食物有鸡肉罐头月饼等,还喝了饮料,最后我们还赏了月。
    张殿凯阅读 695评论 0 1
  • 海门林纳(Hämeenlinna)是芬兰的南部城市,位于赫尔辛基西北97公里。海门林纳原名哈梅城堡,兴建于1308...
    慕溪北欧旅游阅读 1,332评论 0 0
  • 你有没有遗憾的事………… 有没有未完成的事………… 可惜的事……伤心的事…… 世上没有后悔药………… 但………… ...
    大雄的哆啦阅读 1,293评论 1 1