简体   繁体   English

使用 .gitignore 忽略完整目录

[英]Using .gitignore to ignore a full directory

I have created a .gitignore file in the root directory of a project, and I would like to ignore an entire folder and anything that gets place within it.我在项目的根目录中创建了一个 .gitignore 文件,我想忽略整个文件夹以及其中的任何内容。

My .gitgnore file contains only the following:我的 .gitgnore 文件仅包含以下内容:

/dir/output/*

But everytime I add or modify files within the output directory the changes get tracked.但是每次我在输出目录中添加或修改文件时,都会跟踪更改。 Is there a way to do this?有没有办法做到这一点?

You have to tell git to remove the cache before it starts "listening" to the new ignore.你必须告诉 git 在它开始“监听”新的忽略之前删除缓存。 Make sure you commit your changes first and then do the following command:确保先提交更改,然后执行以下命令:

git rm . -r --cached
git add .
git commit -m "what ever message"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM