简体   繁体   English

Git 上 Windows:如何忽略名称中包含点的文件夹

[英]Git on Windows: How do I ignore a folder that has dots in its name

I have a directory like that:'dir1/dir2/blah.blah.blah.blah/' 'blah.blah.blah.blah' is folder how do I add it to.gitignore?我有一个这样的目录:'dir1/dir2/blah.blah.blah.blah/''blah.blah.blah.blah'是文件夹我如何将它添加到.gitignore?

I tried: dir1/dir2/blah.blah.blah.blah/*我试过:dir1/dir2/blah.blah.blah.blah/*

You need to escape the .你需要逃避. in your .gitignore file like this:在您的.gitignore文件中,如下所示:
blah\.blah\.blah\.blah

If this does not work, you probably added the directory to git earlier.如果这不起作用,您可能在之前将目录添加到 git。 In this case, you need to remove it from git ( git rm <directory> and then git commit ) but this will also remove it from the working directory, so backup the files if you still need them!在这种情况下,您需要将其从 git 中删除( git rm <directory>然后git commit )但这也会将其从工作目录中删除,所以如果您仍然需要它们,请备份文件!
Use git ls-files dir1/dir2/ as suggested by torek in the question's comments to check if the directory has been added to git.使用问题评论中 torek 建议的git ls-files dir1/dir2/检查该目录是否已添加到 git。

To remove a file or directory from repository, you can use this:要从存储库中删除文件或目录,您可以使用以下命令:

git rm -r --cached <file/directory>
git commit -m "removes <file/directory>"

This will not remove anything from the history though.但是,这不会从历史记录中删除任何内容。 The files can still be accessed when checking out an older commit.签出较旧的提交时,仍然可以访问这些文件。
It will also not remove the actual files in the directory, it will just make git not longer track them.它也不会删除目录中的实际文件,只会使 git 不再跟踪它们。

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

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