views:

473

answers:

2

I am having an issue with rebasing from master on to a 'deploy' branch within one of my repositories.

My repo is setup as follows:

master - of course, the main branch
deploy - a branch created where files like Capfile, deploy.rb etc are created and configured - these changes will NEVER be merged back into Master

Generally my workflow is:

  1. Do development on the master branch... test, smile, commit.
  2. Checkout the deploy branch
  3. Execute git rebase master on the deploy branch - this used to work without a problem
  4. Push to remote and then execute cap deploy
  5. Relax

The problem I am now having is that when I execute git rebase master on the deploy branch it is coming up with a 3-way merge/manual merge required error (I don't think the error message is really generic enough to post). Git tells me to perform a merge then use git rebase --continue to finish - which never works.

What I have found 'does' work is running git rebase master --interactive, cleaning up the pick list (there is 5 or so repeated 'commits' but with different reference numbers (same message) in this list, so I'll choose one of them) and then manually do the merge. Once I have done this for each commit then I can continue the rebase and its all happy...

Until next time I need to perform a rebase.

So does anyone know what might be happy? The project isn't really 'secret' so if need be I can post messages, logs, branch graphs etc.

Thanks

A: 

You could define an attribute in the parent directory of your "deploy-specific" files, in order to always select the content of the deploy branch in case of merge.

For an example of merge manager, see this SO answer.

Other strategies have been discussed, but the key remain: always consider a merge as "a project-wide merge" and not a file-based merge. Hence the attributes to refine that project-wide merge when it comes to some "special" files.

VonC
+2  A: 

To get git rebase --continue to work you have to actually merge the conflicted files (edit them, pick the parts you want from between the conflict markers “<<<<<<<”, “=======”, “>>>>>>>”) and then git add them to the index (the index is where they are recorded as conflicted, adding a file clears its conflicted state). Check the current diff with git diff --cached, then git rebase --continue if it looks right.

Before you attempt your rebase (or after aborting a problematic one), check out git log -p master..deploy to view the commits that you are trying to rebase. It is one of these that is conflicting with whatever you have in master.

Those commits that you are dropping by deleting their ‘pick’ lines in git rebase -i might not be exactly the same (even though they have the same ‘subject’ in their commit message). The fact that you think there should only be one of them indicates that something fishy is going on with your deploy branch. Are these ‘duplicate’ commits at the tip of deploy or are there other commits after them? Maybe seeing the content of those ‘fishy’ commits (log -p, above) will give you a clue as to their source.

Chris Johnsen