Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git cherry-pick says local changes exist, but git status says nothing

$ git cherry-pick 5de83068
error: Your local changes to the following files would be overwritten by merge:
        Components/ApplicationEnums/Application.cs
Please, commit your changes or stash them before you can merge.
Aborting

$ git status
# On branch master
nothing to commit (working directory clean)

UPDATE Sorry, I switched to another branch, and switched back again, and can't reproduce this anymore :(

like image 862
Benjol Avatar asked Nov 24 '10 06:11

Benjol


People also ask

Why is cherry-pick commit empty?

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.

How do I cherry-pick commit locally?

In order to cherry-pick changes, you will need to identify your commit hashes. In order to see the commit hashes for your current branch, simply run the “git log” command with the “–oneline” option in order to make it more readable.


2 Answers

I had this issue. Error was - error: Your local changes would be overwritten by cherry-pick. hint: Commit your changes or stash them to proceed. fatal: cherry-pick failed The reason for me was I had a file in staging area that I don't wants to commit. I moved that file from staging area and tried to chery-pick again and that was a success.

like image 152
Nimmi Mathew Avatar answered Oct 16 '22 01:10

Nimmi Mathew


I'm not quite sure whats the problem but you can reset your working copy with the follwing statement:

git reset --hard origin/master
like image 28
scheffield Avatar answered Oct 15 '22 23:10

scheffield