tags:

views:

25

answers:

1

Hi all,

I've already did an extensive search, read a lot of SO questions and solutions and tried it different ways, but I've been unable to do what I want, which is fairly simple.

I have the master branch, where all the main code resides, and the design branch, where the layout of the rails application is built by the design team. They have added a folder called "photoshop" to the public folder to keep their sources for the images also under version control. But I don't want this folder to be copied on merge to the master branch because, well, it is not needed.

Apparently, the way to do this is through a merge driver. So, I've created the "ignore" driver:

[merge "ignore"]
name = always ignore during merge
driver = ignore.sh %0 %A %B

And created the ignore.sh file on my $PATH:

exit 0

I've created the .gitattributes file inside public/, because the photoshop folder should be ignored in whole and it is going to appear under public/:

photoshop  merge=ignore
photoshop/ merge=ignore
photoshop/* merge=ignore
photoshop/**/* merge=ignore

As you can see, I've tried several different patterns to ignoring the whole folder, but it does not work. I believe this is because there is no folder on the master branch, so there's no conflict and so git doesn't use the ignore driver. Is there a way to achieve this without having to create a public/photoshop folder on master?

Thanks!

+1  A: 

Did you try adding a .gitignore file in your master branch, to ignore any photopshop directory content ?
Then a merge from design to master shouldn't add that new directory in master.

If this works, you still needs a merge driver, but this time to manage the content of the .gitignore file.

VonC
Or you could just put .gitignore in your $HOME (i.e., outside your rails directory) and enjoy :)
rmk
@rmk: very true, but it could be interesting to have this setting (ignoring '`photoshop`' in '`master`' branch) pushed from repo to repo.
VonC
It is not accepting the merge: error: Untracked working tree file 'public/photoshop/photoshop/bar.psd' would be overwritten by merge. Aborting
Felipe Koch
@Felipe: Could you reset your master branch to a cleaned content first (do a git stash first if you have work in progress not yet committed): `git clean -n -d .` or `git checkout -f master` (as in http://railsdog.com/blog/2008/08/untracked-working-tree-file-blah-would-be-overwritten-by-merge). And then do the merge (note: the updated `.gitignore` file should be committed first, before attempting the merge)
VonC
That's what I did. My current working tree is clean. The git clean indicated that log/, tmp/ and test/integration would be removed.
Felipe Koch
@Felipe: strange, maybe the `gitignore` is not compatible with the merge in this case.
VonC
Yes, I did another test on a temporary folder and gitignore is ignored during merge...
Felipe Koch
@Felipe: good to know. I am still looking for an option which might make a merge conforming to local `.gitignore` directives.
VonC