dialogik
dialogik

Reputation: 9552

Merge conflict although file should be ignored

I have two branches I am working in, develop and staging. First one is for development purposes, the second one is for a deployment which is basically the development code on a test deployment where I add dummy data to the database.

I keep some files from graphic design in the develop branch, e.g. Adobe Photoshop files. Surely I don't need or want them in my staging branch, so I added the folling line into my .gitignore file (it's a subfolder which contains all those files):

...
/gfx_material/

And I had removed the files from the staging branch by executing the following command on the unwanted files (found in this answer):

git rm --cached

Now in the develop branch there have been modifications on files in the /gfx_material/ folder. And when trying to merge the files from develop into staging I get the error:

$ git merge develop
CONFLICT (modify/delete): gfx_material/path/file.psd deleted in HEAD and
modified in develop. Version develop of gfx_material/path/file.psd left in tree.
Automatic merge failed; fix conflicts and then commit the result.

Why? Shouldn't this file (and others in that folder) be ignored?

Upvotes: 0

Views: 202

Answers (1)

John Szakmeister
John Szakmeister

Reputation: 47122

It appears that while you deleted it on the staging branch, someone modified it on the develop branch (that's the modify/delete that you see in the error). If no one had touched it, it'd be okay, but someone did and now Git doesn't know the correct course of action to take.

Also, you may have deleted the files on staging but that wasn't done on development. It sounds like you're trying to use git as a deployment tool and want to strip unnecessary artifacts from the branch. I'd recommend not using Git this way. Rather, you should put together a script to grab the relevant pieces, and deploy them onto your server. It may be nice to use Git that way--because it feels easy--but then you start doing things like deleting the PSD files that lead to development/merge headaches.

Upvotes: 1

Related Questions