有时候,发现有不该提交的文件已经提交后,仅仅在.gitignore中加入忽略是不行的。这个时候需要执行:

git rm -r --cached 文件/文件夹名字    // git rm -r --cached .

去掉已经托管的文件,然后重新提交:

1.git add .

2.git commit -m ''

修改 .gitignore 规则后不生效的解决办法
 

当我们需要删除暂存区或分支上的文件, 同时工作区也不需要这个文件了, 可以使用:

git rm file_path

git commit -m 'delete somefile'

git push

相关文章:

  • 2021-05-16
猜你喜欢
  • 2022-02-20
  • 2022-02-27
  • 2022-12-23
  • 2021-06-01
  • 2018-03-31
相关资源
相似解决方案