0

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?

Community
  • 1
  • 1
Gottlieb Notschnabel
  • 9,408
  • 18
  • 74
  • 116

1 Answers1

1

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.

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
  • Yeah sure I didn't delete it on the `develop` branch - I want to keep it there. But I see, I shouldn't use git as a deployment tool... But shouldn't this work flawlessly if I have different `.gitignore` files in both branches? – Gottlieb Notschnabel Oct 21 '13 at 15:10
  • 1
    No, it shouldn't. In the develop branch, the files are still being versioned, and so Git will still track changes to them. `.gitignore` only specifies which kind of untracked files you want to ignore. But the files are tracked and, therefore, not ignored. At issue is the you think they're unimportant, and deleted them, but the rest of the team thinks they are important and are modifying them. So how should Git resolve the issue? The answer: present a conflict and let the user decide, which is what it's doing. – John Szakmeister Oct 21 '13 at 15:36