git 如何从一个分支到另一个分支挑选樱桃

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5304391/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 10:21:30  来源:igfitidea点击:

How to cherry pick from 1 branch to another

gitcherry-pickgit-cherry-pick

提问by michael

I have 2 branches, masterand dev.

我有 2 个分支,master并且dev.

I am on devbranch and I want to cherry-pick 1 commit from masterto dev. So I did

我在dev分支上,我想从masterto 中挑选 1 个提交dev。所以我做了

$ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad
Finished one cherry-pick.

But when I do git statusand gitx, I don't see my commit be530cec7748e037c665bd5a585e6d9ce11bc8adin git history.

但是当我执行git statusand 时gitx,我be530cec7748e037c665bd5a585e6d9ce11bc8ad在 git 历史中看不到我的提交。

How can I see my commit in the devbranch?

如何在dev分支中查看我的提交?

回答by CanSpice

When you cherry-pick, it creates a new commit with a new SHA. If you do:

当您挑选时,它会创建一个带有新 SHA 的新提交。如果你这样做:

git cherry-pick -x <sha>

then at least you'll get the commit message from the original commit appended to your new commit, along with the original SHA, which is very useful for tracking cherry-picks.

那么至少您会从附加到新提交的原始提交中获得提交消息,以及原始 SHA,这对于跟踪精选内容非常有用。