在Git中使用SASS,我要忽略哪些文件,如何忽略?

时间:2023-01-13 21:47:36

I've got a framework in my /project directory, where I have multiple .sass-cache folders.

我在/项目目录中有一个框架,其中有多个.sass-cache文件夹。

For example, I could have this

例如,我可以有这个

/project/-/-/one/.sass-cache

And this

/project/-/-/two/.sass-cache

And this

/project/three/.sass-cache

And I want to add all of the to .gitignore. I've tried this:

我想把所有的加到。gitignore中。我已经试过这个:

# Sass #
###########
*.sass-cache*

But it fails and git still picks up changes in them. How do I properly add my .sass-cache folders to my .gitignore file?

但是它失败了,git仍然会在其中进行更改。如何正确地将.sass-cache文件夹添加到.gitignore文件中?

5 个解决方案

#1


39  

With .gitignore, a single asterisk is only a wildcard for a specific directory. If your git version is up-to-date, you should be able to use the double asterisk to indicate any level of subdirectories.

对于.gitignore,单个星号只是特定目录的通配符。如果您的git版本是最新的,您应该能够使用双星号来指示任何级别的子目录。

Single asterisk will only match files for that directories depth

单个星号将只匹配该目录深度的文件

foo/*/* == foo/bar/file.xyz
foo/*/* != foo/bar/dir/file.xyz
foo/*/* != foo/file.xyz

Two asterisks matches any directory depth

两个星号匹配任何目录深度

foo/** == foo/bar/file.xyz
foo/** == foo/bar/dir/file.xyz
foo/** == foo/file.xyz

For your case, I would suggest trying the following...

对于你的情况,我建议你试试以下方法……

**/.sass-cache
**/.sass-cache/*

Lastly, I don't know if it would work, but you might also try...

最后,我不知道这是否可行,但你也可以试试……

**.sass-cache**

On this last one, I'm not sure how the double-asterisk would get interpreted. The two lines above this should work fine though.

在最后一个,我不确定双星号如何解释。上面的两条线应该没问题。

#2


19  

I just use

我只是使用

.sass-cache
.sass-cache/*

And that seems to work fine.

看起来效果不错。

#3


1  

One more thing.You should add **.css.map in your .gitignore.

一件事。你应该添加* * . css。在你的.gitignore地图。

#4


0  

I'm using

我使用

.sass-cache/
*.css.map

as especified in github's gitignore descriptions (https://github.com/github/gitignore/blob/master/Sass.gitignore), it seems to work having .sass.cache files at whatever level in the project folder.

特别是在github的gitignore描述中(https://github.com/github/gitignore/blob/master/Sass.gitignore),它似乎有了。sass。在项目文件夹中的任何级别缓存文件。

#5


-2  

Hello for my own only work for this resource:

你好,我唯一的工作为这个资源:

**/.sass-cache/*

Thats because whatever place we start compiling sass (from whatever root position inside proyect) it create a new .sass-cache

这是因为无论我们从哪里开始编译sass(从proyect内部的任何根位置),它都会创建一个新的.sass-cache

#1


39  

With .gitignore, a single asterisk is only a wildcard for a specific directory. If your git version is up-to-date, you should be able to use the double asterisk to indicate any level of subdirectories.

对于.gitignore,单个星号只是特定目录的通配符。如果您的git版本是最新的,您应该能够使用双星号来指示任何级别的子目录。

Single asterisk will only match files for that directories depth

单个星号将只匹配该目录深度的文件

foo/*/* == foo/bar/file.xyz
foo/*/* != foo/bar/dir/file.xyz
foo/*/* != foo/file.xyz

Two asterisks matches any directory depth

两个星号匹配任何目录深度

foo/** == foo/bar/file.xyz
foo/** == foo/bar/dir/file.xyz
foo/** == foo/file.xyz

For your case, I would suggest trying the following...

对于你的情况,我建议你试试以下方法……

**/.sass-cache
**/.sass-cache/*

Lastly, I don't know if it would work, but you might also try...

最后,我不知道这是否可行,但你也可以试试……

**.sass-cache**

On this last one, I'm not sure how the double-asterisk would get interpreted. The two lines above this should work fine though.

在最后一个,我不确定双星号如何解释。上面的两条线应该没问题。

#2


19  

I just use

我只是使用

.sass-cache
.sass-cache/*

And that seems to work fine.

看起来效果不错。

#3


1  

One more thing.You should add **.css.map in your .gitignore.

一件事。你应该添加* * . css。在你的.gitignore地图。

#4


0  

I'm using

我使用

.sass-cache/
*.css.map

as especified in github's gitignore descriptions (https://github.com/github/gitignore/blob/master/Sass.gitignore), it seems to work having .sass.cache files at whatever level in the project folder.

特别是在github的gitignore描述中(https://github.com/github/gitignore/blob/master/Sass.gitignore),它似乎有了。sass。在项目文件夹中的任何级别缓存文件。

#5


-2  

Hello for my own only work for this resource:

你好,我唯一的工作为这个资源:

**/.sass-cache/*

Thats because whatever place we start compiling sass (from whatever root position inside proyect) it create a new .sass-cache

这是因为无论我们从哪里开始编译sass(从proyect内部的任何根位置),它都会创建一个新的.sass-cache