Joshua Soileau
Joshua Soileau

Reputation: 3015

Using SASS with Git, what files do I ignore and how?

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

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:

# 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?

Upvotes: 29

Views: 28872

Answers (6)

domdaviesdev
domdaviesdev

Reputation: 89

For those of you who set up your workflow with 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...

source. traversy media video "Responsive Portfolio, SASS workflow setup"

Upvotes: 0

Tati
Tati

Reputation: 95

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.

Upvotes: 3

jiexishede
jiexishede

Reputation: 2613

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

Upvotes: 4

nandoOverFLow
nandoOverFLow

Reputation: 11

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

Upvotes: -2

eddiemoya
eddiemoya

Reputation: 7478

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.

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.

Upvotes: 43

chipcullen
chipcullen

Reputation: 6960

I just use

.sass-cache
.sass-cache/*

And that seems to work fine.

Upvotes: 21

Related Questions