1

Lets say while working on feature branch A, someone else merged a large pull request that significantly modifies the structure of the project (splits it into smaller Maven projects)

How can I cherry pick my work over to the master branch that has now changed into a particular folder?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Alex C
  • 503
  • 1
  • 4
  • 10
  • Hmmm... Carefully resolving conflicts, no magic here. But try to merge first, it may come up with easier conflict resolution. – kan Mar 30 '16 at 13:53
  • 1
    As you probably suspect, you'll have to resolve the conflicts. If you're lucky, `git mergetool` will help. But if the changes are too great, you'll have to manually redo your work to suit the changes. There is no magical way to avoid this additional work. Btw, I'll mark your question as dupe, because there really is nothing more to it. You'll have to resolve the conflicts. – sashoalm Mar 30 '16 at 13:55
  • Possible duplicate of [Fix merge conflicts in Git?](http://stackoverflow.com/questions/161813/fix-merge-conflicts-in-git) – sashoalm Mar 30 '16 at 13:55

1 Answers1

0

The usual best practice is to rebase your local commits on top of the updated remote tracking branch

git checkout abranch
git fetch
git rebase origin/abranch

That is the equivalent of cherry-picking your commits, except the rebase will do that for you.

But in this instance, instead of cherry-picking or rebasing, it might be easier to do a git merge --squash --no-ff origin/aBranch.
As mentioned in "Differences between git merge --squash and --no-commit", it's almost like you did a cherry-pick on all the merged changes.

That is preferable to a rebase which would attempts to replay your commits on top of a project working tree whose structure has considerable changed.

You will still have conflict to solve, but only in one step.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250