简体   繁体   English

仅从远程拉出最后一次提交并将其放在顶部

[英]pull only the last commit from remote and put it on the top

I've got commits on two remotes 我在两个遥控器上提交了内容

origin 1-2-3-4-5-A
upstream 1-2-3-4-5-6-7

On my local machine I've got the upstream version of commits. 在我的本地计算机上,我具有提交的上游版本。

But the question is how to acquire the commit A from origin and put it on the top of my current commits? 但是问题是如何从来源获取提交A并将其置于我当前的提交之上? I mean the result should be 1-2-3-4-5-6-7-A . 我的意思是结果应该是1-2-3-4-5-6-7-A

That's exactly what git cherry-pick is for. 这正是git cherry-pick目的。

Switch your local repo to the branch that you want to change. 将本地存储库切换到要更改的分支。 Then: 然后:

git cherry-pick A

You can specify the commit with its SHA hash, or you can just use the branch name to pick the last commit. 您可以使用其SHA哈希值指定提交,也可以只使用分支名称来选择最后一个提交。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM