git 将最后一次提交从 master 复制到分支
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13006135/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Copy last commits from master to branch
提问by marioosh
Present situation in the picture. Green branch is a master. How to copy last 3 commits from master to pink branch, but without touching a master ?
图中的现状。绿枝是高手。如何将最后 3 个提交从 master 复制到粉红色分支,但不接触 master ?
回答by Amber
git checkout <name of pink branch>
git merge master
will do exactly what you want (merge the 3 commits from master
into the pink branch, but leave master
itself where it is).
将完全按照您的意愿执行(将 3 个提交合并master
到粉红色分支中,但将master
其保留在原处)。
回答by Ben Hymanson
If you mean you wished you had waited to branch (and it's a personal project branch) you can (from branch "pink") use git rebase master
. That will pop off the pink commits, move pink
ahead to 29934b6 and then re-apply the patches.
如果您的意思是您希望等待分支(并且它是个人项目分支),则可以(从分支“粉红色”)使用git rebase master
. 这将弹出粉红色的提交,pink
前进到 29934b6,然后重新应用补丁。
Otherwise Amber's git merge
is probably the best answer.
否则,Amber'sgit merge
可能是最好的答案。
Another possibility is (again, from "pink") git cherry-pick 9a51fd2; ...
for each of those changes. That will make individual new commits on pink. You can also name the branches as master
, master^
and master^^
.
git cherry-pick 9a51fd2; ...
对于这些更改中的每一个,另一种可能性是(再次来自“粉红色”)。这将使粉红色的单个新提交。您还可以将分支命名为master
,master^
和master^^
。