0

I have 3 branches dev, backup, and release. backup was created from dev, the release was created from backup. Now I have new changes in dev. only one commit should go in the release branch. so I am trying to use cherry-pick from dev to backup and then new PR from backup to release but I am getting errors while doing the same.

I am trying to use cherry-pick from one branch to another but getting the following error

E:\Java\Projects\Test-db\Test_db>git cherry-pick 876c951b5012e4ab87a9be9521
error: Commit 876c951b5012e4ab87a9be9521 is a merge but no -m option was given.
fatal: cherry-pick failed

Then by looking at this link [https://stackoverflow.com/questions/12626754/git-cherry-pick-syntax-and-merge-branches/12628579] I tried -m with cherrypick command but getting following

E:\Java\Projects\Test-db\Test_db>git cherry-pick -m 1 876c951b5012e4ab87a9be9521
On branch Java-develop-backup-2021-01-20
You are currently cherry-picking commit 876c951.

Untracked files:
        mvn

nothing added to commit but untracked files present
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty

Otherwise, please use 'git reset'

E:\Java\Projects\Test-db\Test_db>

I tried git commit --allow-empty but it is opening following

#
# It looks like you may be committing a cherry-pick.
# If this is not correct, please remove the file
#       .git/CHERRY_PICK_HEAD
# and try again.


# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author:    ABC Rokade <ABC.rokade@testcompnay.com>
# Date:      Wed Jan 20 14:49:10 2021 +0000
#
# On branch Java-develop-backup-2021-01-20
# You are currently cherry-picking commit 876c951.
#
# Untracked files:

I am not sure what needs to do further. Could you please help me to resolve the error while using a simple cherry-pick command?

stackUser
  • 545
  • 3
  • 9
  • 21
  • 1
    Are you sure you need to cherry-pick a merge? What's the end goal? – Romain Valeri Jan 20 '21 at 16:51
  • @RomainValeri please check the updated question for more details. – stackUser Jan 20 '21 at 16:57
  • 2
    I don't see any new element to answer my questions. I smell an XY problem, that's the reason I'm asking about your end goal. Which is still unknown. If you need some changes present in a commit, cherry-pick it, rather than the merge which included it. – Romain Valeri Jan 20 '21 at 17:03
  • 2
    `The previous cherry-pick is now empty, possibly due to conflict resolution` - This means that the changes in this commit (876c951) are already present on your branch . – Dev-vruper Jan 20 '21 at 17:05
  • 1
    As for the last screen: it's `vim` editor. Learn it a bit: https://stackoverflow.com/a/11828573/7976758 or change it to your preferred editor. – phd Jan 20 '21 at 18:17
  • @Dev-vruper you are right. I did check in the backup branch and the code was already merged. I think I was merged when I performed cherry-pick first time...there was an error at that time as well so I did not check in a branch instead I kept trying to resolve the error. – stackUser Jan 21 '21 at 18:03

0 Answers0