How to cherry-pick from a remote branch?

后端 未结 10 525
长发绾君心
长发绾君心 2020-12-07 11:17

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

10条回答
  •  醉梦人生
    2020-12-07 12:11

    Since "zebra" is a remote branch, I was thinking I don't have its data locally.

    You are correct that you don't have the right data, but tried to resolve it in the wrong way. To collect data locally from a remote source, you need to use git fetch. When you did git checkout zebra you switched to whatever the state of that branch was the last time you fetched. So fetch from the remote first:

    # fetch just the one remote
    git fetch 
    # or fetch from all remotes
    git fetch --all
    # make sure you're back on the branch you want to cherry-pick to
    git cherry-pick xyz
    

提交回复
热议问题