2

There was two long parallel running Git branches - e.g. master and featureXY. Because of conflicts I had to cherry-pick commits from featureXY into master (and do some manual modifications). Now we have all changes "merged" back to master, but we need to featureXY branch stay open to make future develop changes.

I did a cherry-picking with this command:

git cherry-pick -x {SHA-1}

But when now I run to get all changes that do not exist in master

git cherry -v master featureXY

I get all the changes, even those that were cherry-picked and manually edited.

Question: is there some command to ensure that when I run

git checkout master
git merge featureXY

to do not harm all previous cherry-picked commits? Some kind of "do not merge commits before this commit" command?

jnemecz
  • 3,171
  • 8
  • 41
  • 77

1 Answers1

1

The simplest option might be to delete the branch and create a new branch from master with the same name.

However, I think what you're looking for is what I would call a "dummy merge": you want to tell git that everything is merged, without actually changing any files. This can be achieved using the "ours merge strategy"; according to the git manual:

This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the recursive merge strategy.

So you would first check out a clean copy of master, and then run:

git merge -s ours featureXY

This should result in a merge commit that records the current state of featureXY as an ancestor, but doesn't actually change any files.

IMSoP
  • 89,526
  • 13
  • 117
  • 169