• Skip to primary navigation
  • Skip to main content
Sal Ferrarello
  • About Sal Ferrarello
  • Speaking
  • Connect
    Mastodon GitHub Twitter (inactive)
You are here: Home / Computing / Git Conflict Compiled Sass Files
Picture of a Tag that Might be Found on Luggage

Git Conflict Compiled Sass Files

Last updated on March 19, 2014 by Sal Ferrarello

I’ve been using both Git and Sass for some time now. These two tools have had a huge positive impact on my development. The issue that arises when combining Git and Sass is when checking in compiled CSS, it is common to get conflicts with other contributors on the Git repository.

Don’t Check in Your Compiled Files

The short answer is to preventing Git conflicts from Sass compiled files is don’t check in your compiled files. This is done via your .gitignore file and works great. You can view .gitignore file for my the Bootstrap Genesis Starter Theme at https://github.com/salcode/bootstrap-genesis/blob/master/.gitignore

Notice, the lines
js/javascript.min.js
and
css/style.min.css,
excluding these compiled files form the Git repo.

What About People Without Sass?

The question that arises when you stop checking in your compiled files is, “What about people without Sass?”  For developers who are contributing to a project, I think Sass is a fair requirement; however, if someone wants to download your project (e.g. a WordPress theme), it is unusable without Sass to compiled the css.

Making Compiled Files Available While Avoiding Conflicts

The solution is to create a branch, commit the compiled files to the branch, and then tag the branch with a release number.  This allows you to create tagged releases that include the compiled files that users can download and use without doing any compilation themselves.  You can see an example of this at https://github.com/salcode/bootstrap-genesis/releases.  It is worth noting, the branch with the compiled files is never merged into your master branch.

Steps to Create a Tagged Release with Compiled Files

# create and switch to new branch "tag-branch"
git checkout -b tag-branch
# add compiled files
git add -f css/style.min.css
git add -f js/javascript.min.js
# commit with compiled files
git commit -m 'add compiled files'
# create a tag for commit that includes the compiled files
git tag -a v0.7 -m "Version 0.7 Stable"
# push the tags up to your remote repository (e.g. GitHub)
git push --tags
# switch back to the master branch
git checkout master
# delete the branch you used for your tagged commit
git branch -D tag-branch
view raw git-steps-create-tagged-release-w-compiled-files hosted with ❤ by GitHub

Example

Screen Capture of Applying The Steps to Create a Tagged Release with Compiled Files

Thanks to Scott González for explaining the process of creating a tag version that includes the compiled files.

Sal Ferrarello
Sal Ferrarello (@salcode)
Sal is a PHP developer with a focus on the WordPress platform. He is a conference speaker with a background including Piano Player, Radio DJ, Magician/Juggler, Beach Photographer, and High School Math Teacher. Sal can be found professionally at WebDevStudios, where he works as a senior backend engineer.

Share this post:

Share on TwitterShare on FacebookShare on LinkedInShare on EmailShare on Reddit

Filed Under: Computing, Dev Tips, Programming Tagged With: Git, Sass, website

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Copyright © 2023 · Bootstrap4 Genesis on Genesis Framework · WordPress · Log in