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/feature_continuum.info
git add web/sites/all/modules/custom/feature_continuum/feature_continuum.info
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
Comments
Post new comment