Pregunta

One of my team members was working on a feature branch. He then merged our master branch into his feature branch, but apparently only took his changes, none of the (large) changes from master are recorded in the merge.

So the commit looks like:

Commit: 1a168acc1bbabcdc68ad6310e8cf521cc32cc708 [1a168ac]
Parents: cf8f0a4898, 59232d8d24

Check-in comments about minor changes to two small files

So effectively he wiped out the changes in master.

Then another few commits were applied to the feature branch, and he issued a pull request (We use GitHub, and he's pushed his branch there).

Now when I do a merge, it of course un-does all the important changes on master. What I would like to do is correct the broken merge, if that is possible. Or redo the merge. Or even extract the diffs from that commit and just reapply them at an earlier point.

In this case the commits are small enough to repeat by hand, but I'd like to know how to do this correctly.

¿Fue útil?

Solución

I'm not sure this the best solution, but I reset my head to the commit just before the bad 'merge'. Then I found that by doing a cherry-pick of the merge commit and choosing the feature branch as mainline I could get the commit without the merge tracking:

git cherry-pick 1a168acc -m 1

Since this branch only had one more commit after this one, I just cherry picked that branch onto my new detached head and created a new branch, then merged master into the new branch without any problems.

If there had been a series of commits after the merge, I'm not sure what the correct solution would have been.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top