CSS 在 Git 中使用 SASS,我应该忽略哪些文件以及如何忽略?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20430291/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using SASS with Git, what files do I ignore and how?
提问by Joshua Soileau
I've got a framework in my /project
directory, where I have multiple .sass-cache
folders.
我的/project
目录中有一个框架,其中有多个.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
文件中?
回答by eddiemoya
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.
在最后一个中,我不确定如何解释双星号。不过,上面的两行应该可以正常工作。
回答by chipcullen
I just use
我只是用
.sass-cache
.sass-cache/*
And that seems to work fine.
这似乎工作正常。
回答by jiexishede
One more thing.You should add **.css.map
in your .gitignore
.
还有一件事**.css.map
。你应该添加你的.gitignore
.
回答by Tati
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.cache 文件。
回答by Dominic Davies
For those of you who set up your workflow with npm install node-sass.
对于那些使用 npm install node-sass 设置工作流程的人。
- Before you do git init do the following
- create .gitignore in root of your project
- the .gitignore file will be blank in your code editor
- in the .gitignore file type node_modules
- now all your dependencies won't be added to your repository
- now do your git init etc...
- 在执行 git init 之前,请执行以下操作
- 在项目的根目录中创建 .gitignore
- .gitignore 文件在您的代码编辑器中将是空白的
- 在 .gitignore 文件类型 node_modules
- 现在您的所有依赖项都不会添加到您的存储库中
- 现在做你的 git init 等...
source. traversy media video "Responsive Portfolio, SASS workflow setup"
来源。遍历媒体视频“响应式投资组合,SASS 工作流设置”
回答by nandoOverFLow
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