29

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?

Joshua Soileau
  • 2,933
  • 9
  • 40
  • 51

6 Answers6

42

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.

eddiemoya
  • 6,713
  • 1
  • 24
  • 34
20

I just use

.sass-cache
.sass-cache/*

And that seems to work fine.

chipcullen
  • 6,840
  • 1
  • 21
  • 17
  • 1
    I should add that my sass-cache directories are several directories deep compared to where the git ignore file is. – chipcullen Dec 06 '13 at 17:55
  • That sounds like it should work for me, but it doesn't look like it. Isn't there some kind of cached git tree that I need to clear to make it forget changes it might have already noticed in those directories? – Joshua Soileau Dec 06 '13 at 18:14
  • Dang, I'm far from a git expert, but I have had success with the above config in my git ignore file. Would the answer here: http://stackoverflow.com/questions/5810233/git-ignores-content-of-gitignore help? – chipcullen Dec 06 '13 at 18:20
  • 4
    This should be enough, but remember that if this directory has already been tracked, you'll need to untrack that directory. See if it's tracked with `git ls-tree -r master --name-only`. Untrack it with `git rm -r --cached ./.sass-cache` – daleyjem Mar 12 '15 at 02:43
  • Thanks for the untrack tip, that helped me. – iamkeir Mar 19 '15 at 13:41
3

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

jiexishede
  • 2,473
  • 6
  • 38
  • 54
3

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.

Tati
  • 95
  • 4
0

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"

domdaviesdev
  • 89
  • 1
  • 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