tags:

views:

142

answers:

2

I'm trying to keep my static files in a separate branch so that I can keep them from merging into my master brach (on Heroku, your application's slug needs to stay small). I don't want to ignore my static files, because I want to keep them inside my "devel" branch.

Ideally I'd like to keep test.db blank and my entire public folder blank in the master branch.

So, can I create an 'overlay' onto a branch? Can I prevent certain files/directories from merging into my master branch?

+8  A: 

You could define those same static files on your master branch but:

Since that .gitattribute would not be define on other branches, the merge of those files would proceed normally.


The idea is to define a .gitattributes file in the directory of those static files on the master branch with the following content:

myStaticFile1 merge=keepMine
myStaticFile2 merge=keepMine
myStaticFile3 merge=keepMine

Those three files will always keep their local content (which is empty on master) when merging to master.

You will have to define a merge driver (here called "keepmine"). See the linked question for that script.

VonC
Could you explain in a little more detail? I've not used attributes before and the link isn't 100% straightforward.
arbales
awesome – thanks for the explanation!
arbales
Also, I don't seem to be able to define wildcards, I tried public/* merge=keepMine, which didn't work. I also tried removing the directory and touching it, making a file, but Git complains and makes another version of public on merge.
arbales
A: 

Add the files to .gitignore in master. When you checkout devel, .gitignore will change and won't ignore them anymore. (Note that if you run git clean -x, the files will be overwritten.)

Kat Magic