从不同的回购中挑选提交

Cherry-pick Commit from a different repo

我试图挑选这个提交

https://github(dot)com/AICP/frameworks_base/ 到 https:// github(点)com/Gopinaidu7/android_frameworks_base

我创建了一个名为 master 的新分支并切换到它。
然后我做了:

git cherry-pick 59ebfb7

它得到了

fatal: bad revision '59ebfb7'

我也试过:

git cherry-pick 59ebfb7146616e57c15469d7ea85c4362c2fab3c 

遇到了这个错误

fatal: bad object 59ebfb7146616e57c15469d7ea85c4362c2fab3c.

我做错了,我确实试图从昨晚开始挑选那些提交。
我做不到,有人可以按顺序指出我正确的命令吗?

您需要先将另一个存储库添加为远程:

 git clone  https://github.com/Gopinaidu7/android_frameworks_base
 cd android_frameworks_base
 git remote add other https://github.com/AICP/frameworks_base

然后获取:

 git fetch other

现在您可以使用 SHA1 进行挑选。然后推。

如果精心挑选的提交是合并提交:

git cherry-pick -m 1 59ebfb7

您不需要创建新分支,只需按照@Vonc 的建议克隆目标分支,然后运行此命令:

git checkout target_branch
git fetch https://github.com/AICP/frameworks_base && git cherry-pick 59ebfb7

'bad revision' 每当您尝试 cherry-pick 提交并且本地没有该远程分支时,就会出现消息。

解决方案

git fetch origin <remote_committed_branch>
git cherry-pick <commit-id>