I\'m having trouble performing a cherry-pick. On my local machine, I\'m currently on my \"master\" branch. I want to cherry-pick in a commit from another branch, named \"zeb
I had this error returned after using the commit id from a pull request commit id tab. That commit was subsequently squashed and merged. In the github pull request, look for this text: "merged commit xxxxxxx into..." instead of attempting to use the commit ids from the commits tab.
$ git remote add foo git://github.com/foo/bar.git
$ git fetch foo
foo
)$ git log foo/master
$ git cherry-pick 97fedac
This can also be easily achieved with SourceTree:
done :)
If you have fetched, yet this still happens, the following might be a reason.
It can happen that the commit you are trying to pick, is no longer belonging to any branch. This may happen when you rebase.
In such case, at the remote repo:
git checkout xxxxx
git checkout -b temp-branch
Then in your repo, fetch again. The new branch will be fetched, including that commit.
Need to pull both branch data on your local drive first.
What is happening is your trying to cherry-pick from branch-a to branch-b, where in you are currently on branch-b, but the local copy of branch-a is not updated yet (you need to perform a git pull on both branches first).
steps:
- git checkout branch-a
- git pull origin branch-a
- git checkout branch-b
- git pull origin branch-b
- git cherry-pick <hash>
output:
[branch-b <hash>] log data
Author: Author <Author
1 file changed, 1 insertion(+), 3 deletions(-)
Just as an addendum to OP accepted answer:
If you having issues with
fatal: bad object xxxxx
that's because you don't have access to that commit. Which means you don't have that repo stored locally. Then:
git remote add LABEL_FOR_THE_REPO REPO_YOU_WANT_THE_COMMIT_FROM
git fetch LABEL_FOR_THE_REPO
git cherry-pick xxxxxxx
Where xxxxxxx is the commit hash you want.