Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

css

sass

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?

like image 656
Joshua Soileau Avatar asked Dec 06 '13 17:12

Joshua Soileau


People also ask

What files should be ignored in Git?

Ignored files are usually build artifacts and machine generated files that can be derived from your repository source or should otherwise not be committed. Some common examples are: dependency caches, such as the contents of /node_modules or /packages. compiled code, such as .o , .

Where should be the Git ignore file?

gitignore is located in the root directory of your repo. / will ignore directories with the name.


1 Answers

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.

like image 83
eddiemoya Avatar answered Sep 22 '22 20:09

eddiemoya