Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何忽略git中以前跟踪的目录的内容?_Git_Github_Gitignore - Fatal编程技术网

如何忽略git中以前跟踪的目录的内容?

如何忽略git中以前跟踪的目录的内容?,git,github,gitignore,Git,Github,Gitignore,我已经看到不再跟踪以前跟踪的文件,但这里是我的情况 我以前提交过一个目录。我现在想取消跟踪该目录中的所有内容,但仍要跟踪目录本身 我补充说 /auto save list/*到.gitignore文件(我试图忽略的目录是项目根目录中的auto save list目录,我已经运行了git rm--cached,但在我进行提交时,该目录中仍有多个文件显示为新文件。类似地,这些文件显示在我的原始repo中 有人能帮我忽略以前跟踪的文件的内容吗?这就足够了: git rm -r --cached aut

我已经看到不再跟踪以前跟踪的文件,但这里是我的情况

我以前提交过一个目录。我现在想取消跟踪该目录中的所有内容,但仍要跟踪目录本身

我补充说
/auto save list/*
.gitignore
文件(我试图忽略的目录是项目根目录中的
auto save list
目录,我已经运行了
git rm--cached
,但在我进行提交时,该目录中仍有多个文件显示为新文件。类似地,这些文件显示在我的原始repo中

有人能帮我忽略以前跟踪的文件的内容吗?

这就足够了:

git rm -r --cached auto-save-list/
echo "/auto-save-list/" > .gitignore
git add .gitignore
git commit -m "Records untracking of /auto-save-list/ folder"
不需要“
*

如果仍然需要该目录(在Git repo中进行版本控制,即使Git不跟踪空文件夹),请在其中添加一个虚拟文件

touch auto-save-list/.keep
git add -f auto-save-list/.keep
git commit -m "Record auto-save-list/ folder, while ignoring its content"

Git不跟踪目录,只跟踪文件。如果您取消跟踪该目录中的所有内容,该目录也将消失,除非您将文件放入其中。