User login

Procedure for resolving a a left-behind branch that has merge conflicts

DRAFT. Better methods from better minds invited!

Situation: Someone has been working away wonderfully on a git branch on your project. You do some crazy stuff with it over the weekend, and when they, on their continnum branch, go git pull --rebase origin continuum and get conflicts they don't know how to deal with, or when they go git fetch origin and git rebase master and have conflicts.

You want to take this off their hands.

First, ask your colleague who does not want to deal with the merge to share what they have, a copy of the branch they were working on. Ask for these commands to be run, when they are on the branch 'continuum' in this example, making a new branch does so from the branch you are on:

# Get out of the bad merge.
git reset --hard HEAD
# Make a copy of the branch (-copy is just part of the name, not a command).
git checkout -b continuum-copy
# Push the branch to the remote repository
git push origin continuum-copy

Now it's over to you. What do you do to resolve the conflicts?

# Be up to date.
git pull
# See what we have.
git branch -a
# Get the problem-child orphan branch.
git checkout continuum-copy
git pull agaric continuum-copy
# Take a look at the commits.
git log
# Get over to your own version of the branch.
git checkout continuum
# Make sure it is up-to-date with master.
git rebase master
# Make sure the commits you were looking at aren't actually already there.
git log --pretty=oneline | grep 'Continuum'
# Go back to the copy.
git checkout continuum-copy
# Make sure it too is up-to-date with master (useless to separate this out?)
git rebase master
# Start dealing with the conflicts.
vi web/sites/all/themes/issy/template.php
git add web/sites/all/themes/issy/template.php
git rebase --continue
# Conflicts dealt with, go back to continuum and merge it in.
# NOTE:  I think i did this wrong, i should have rebased continuum into
# continuum-copy and then done a conflict-free merge.  But this worked.
git checkout continuum
git merge continuum-copy
# Deal with these conflicts (yeah i did this wrong).
vi web/sites/all/modules/custom/feature_continuum/
git add web/sites/all/modules/custom/feature_continuum/
git commit -m "Explained to git that a new line in a file is not really a merge conflict.

Or tried to explain that, but in any case added the views_load_more dependency
to the Continuum feature .info file."
# Kill the now meaningless branch, with force.  Not sure why lowercase -d didn't work.
git branch -D continuum-copy
# Tell the world you killed it.
git push agaric :continuum-copy
# Push everything else you did.
git push

Searched words: 
git cancel merge


Post new comment

The content of this field is kept private and will not be shown publicly.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.
  • You can use Markdown syntax to format and style the text. Also see Markdown Extra for tables, footnotes, and more.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <img> <blockquote> <small> <h2> <h3> <h4> <h5> <h6> <sub> <sup> <p> <br> <strike> <table> <tr> <td> <thead> <th> <tbody> <tt> <output>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.