这个问题在这里已经有了答案:
Ignore files that have already been committed to a Git repository [duplicate]
(21 个回答)
去年关闭。
我想忽略 dist
文件夹。所以当dist
发生变化时文件夹,它不会出现在 commit
中
在 .gitignore 文件中,存在 /dist
像这样 :
.DS_Store
node_modules
/dist
但是为什么有变化的时候还是会出现呢?
我怎么解决这个问题?
最佳答案
使用 Git,如果您提交文件或文件夹,即使您将其放入 .gitignore
,Git 也会继续跟踪它。 .因为 .gitignore
只是防止添加未跟踪的文件。
要停止跟踪,您必须将其从 Git 索引中删除
git rm -r --cached <folder> // git rm -r --cached dist
它会将文件夹保留在您的本地,但不会再被跟踪。
对于
.gitignore
中的文件夹正确的格式是 dist/
带斜杠
关于git - 如何忽略 .gitignore 文件中的 dist 文件夹?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59561657/