Why is git-cherrypick saying nothing to commit?
Asked Answered
F

6

51

I searched a lot for the below issue but couldn't get any substantial info.

I created a temporary branch 202116 and am trying to do a cherrypick of gerrit 202116 and I get the below message. Why am I not able to cherry-pick this commit and why am I getting this error?

<>git fetch ssh://[email protected]:29418/platform/vendor/company-proprietary/radio refs/changes/25/202116/1 && git cherry-pick FETCH_HEAD
From ssh://company.com:29418/platform/vendor/company-proprietary/radio
 * branch            refs/changes/25/206025/1 -> FETCH_HEAD
# On branch 202116
# You are currently cherry-picking.
#   (all conflicts fixed: run "git commit")
#
nothing to commit, working directory clean
The previous cherry-pick is now empty, possibly due to conflict resolution.
If you wish to commit it anyway, use:

    git commit --allow-empty
Flogging answered 31/12, 2012 at 0:41 Comment(1)
I had the same issue, do git reset --soft HEAD~1, the commit will be removed and you can see the files which are added.Conformist
P
73

It's exactly what it says: the changes you're trying to cherry-pick are already wholly contained in the branch you're on. I.e. the result of the cherry-pick is no changes. You can create an empty commit with the --allow-empty flag to indicate that you attempted to cherry-pick, but there were no changes to pull in.

Paregoric answered 31/12, 2012 at 4:55 Comment(0)
M
4

This could be caused by trying to cherry pick a commit that was already integrated/cherry-picked into your current branch.

Melodee answered 10/10, 2018 at 14:34 Comment(0)
P
3
reset --soft HEAD~1

Once done commit your changes and push them to origin.

Portsalut answered 8/7, 2022 at 4:40 Comment(1)
This does not actually address the whole issue presented but does provide some help towards its solution. It helped me a lot as a first-time cherry-picker.Inane
L
2

I don't know why you do a cherry-pick after fetch, Because you may cherry-pick the same commit with your HEAD.

And is git checkout what you really want? I guess.

Lacroix answered 31/12, 2012 at 2:44 Comment(2)
basically I want cherrypick..I have to do a fetch and cherry-pick ,this is fixed,do you know why the cherry pick is failing?Flogging
According to the error message, the commit cherry-pick has no change upon you HEAD. You can check if the commit of the cherry-pick and the HEAD commit are the same.Lacroix
C
1

In my case, i forked a new branch and then cherry pick some commits on this branch. Because the branch itself is new and not yet committed to remote, Git assumed that there is nothing to commit.

Remember, the changes which we cherry-pick, will appear already as a commit. This can be validated with command git log --oneline.

So, in this case, just pushing the branch to remote would be sufficient.

Cola answered 22/5, 2023 at 11:19 Comment(0)
A
-1

I got this message when I misread my Bitbucket diff page, mistaking the parent commit for the commit I wanted. Thus I was attempting to cherry-pick the parent commit which was already on my working branch - so there was indeed "nothing to commit".

Analogous answered 4/11, 2019 at 15:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.