Reputation: 21526
I am working on a project with a lot of sass files that get compiled into one big style.css
The problem is that this style.css
is always causing problems when merging, but we still want its latest version pushed to the server. What I end up doing - is remove my local style.css
file when merging with master, then compile sass again and only then push everything to remote.
How would I ignore a particular file when merging but still push it to remote when I'm pushing the master branch?
EDIT: Basically I always want my version of this file override the one on master branch without causing conflicts and the rest of the files be merged as usual.
Upvotes: 3
Views: 682
Reputation: 760
EDIT: you may want to do this:
[(*) code and commit]
[don't commit your style.css!]
$ git checkout -- public/style.css # erase your own style.css
$ git pull
[merge if necessary]
[re-generate your style.css] # important!
git commit public/style.css -m "your message here"
git push origin # should be OK.
[go to (*) and go on coding]
I think there are several ways to achieve this.
style.css
might not be tracked by git as it will be generated again.public/
directory with rsync instead of git. In that case, you will not have to keep track of this style.css
.git cherry pick
to merge and override specific files.style.css
to exist in master? If not, maintain a separate branch for your style.css
, ignore the CSS in master
and the style.css
's branch will contain a specific .gitignore
in your public directory containing !style.css
. As a consequence this specific branch will have only 2 files, and you automatically merge master inside.Upvotes: 1
Reputation: 819
As far as i know we can't forcefully push single file
For now what you can do is
1)After runing sass save style.css separately and checkout to current version(only style.css) and push the code.
2) now copy saved style.css and then commit, use git force command to force push it to remote.
git push -f <remote> <branch>
(or)
use git ignore style.css, once ignored it will not be tracked but you will end up with copying latest style.css to server every time
Upvotes: 1