0

I have a master branch and a feature branch.

Feature branch branch has two files deleted

file1
file2

I wanna merge feature branch into master but I want to keep file1 and file2 , I don't want them to be deleted.

if I do cherry-pick on feature branch, I get

git cherry-pick XXX
error: Commit XXX is a merge but no -m option was given.

So basically I want merge tool to popup so I can do a selective merge for the files. But there is no conflicts so it is not poping up.

also this questions is similar but difficult to follow, How do you merge selective files with git-merge?

is there a simpler approach or a visual representation I can pick what to merge?

Community
  • 1
  • 1
Mord Fustang
  • 1,523
  • 4
  • 40
  • 71
  • The `cherry-pick` command is used to find the changes made between a commit and its parent. For a non-merge commit this is well-defined: the commit has exactly one parent, and git can diff the commit and its parent to get those changes. For a merge commit, there are two or more parents: which one did you want to compare? (This is what the `-m` option is for.) In any case, based on your description, it looks like what you want is to do an actual merge, which takes multiple commits into account, rather than just a single commit the way `git cherry-pick` does. – torek Feb 18 '16 at 18:55
  • Why the feature branch you want to pick is a merge? From your description it looks like it should not be. Could you provide more detailed info of what you did? – max630 Feb 19 '16 at 14:02

1 Answers1

0

Try this:

git checkout master             #start on master
git merge feature --no-commit   #merge in feature, but don't commit yet
git checkout HEAD file1         #restore file1 to its state before the merge
git checkout HEAD file2         #restore file2 to its state before the merge
git commit                      #complete the merge commit
David Deutsch
  • 17,443
  • 4
  • 47
  • 54