user1934146
user1934146

Reputation: 3071

Why is git-cherrypick saying nothing to commit?

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

Upvotes: 53

Views: 60769

Answers (6)

Yogesh G
Yogesh G

Reputation: 1160

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.

Upvotes: 2

Abhishek Khaiwale
Abhishek Khaiwale

Reputation: 445

reset --soft HEAD~1

Once done commit your changes and push them to origin.

Upvotes: 5

Fiskabollen
Fiskabollen

Reputation: 81

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".

Upvotes: -1

Hassen Ch.
Hassen Ch.

Reputation: 1761

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

Upvotes: 5

Ryan Stewart
Ryan Stewart

Reputation: 128899

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.

Upvotes: 75

pktangyue
pktangyue

Reputation: 8524

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.

Upvotes: 2

Related Questions