0

Is it possible to cherry-pick a commit from a remote that doesn't belong to any branch? There is a commit in the remote which says: "This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository." When I am trying to cherry-pick it using: git cherry-pick commit_id, I am getting "fatal: bad object" error.

Sonwani
  • 1
  • 1
  • 2

1 Answers1

4

The object you're trying to cherry-pick must be present in your local repository. If it appears in GitHub with that message, then it may belong to a fork of the repository or perhaps a pull request. Because GitHub stores all of the objects for an entire repository network in the same repository, it's possible for an object in any repository in the network to be viewed from any repository.

In order to successfully cherry-pick it, you'll need to use git fetch on some reference (branch, tag, pull request reference) that contains the object. Since it probably belongs to a different fork, you'll need to add that fork as a remote and fetch it first. You'll have to figure out which fork that is; it isn't determinable trivially.

bk2204
  • 64,793
  • 6
  • 84
  • 100