如何从一个分支挑选到另一个分支
我有 2 个分支,master
和 dev
。
我在 dev
分支上,我想从 master
到 dev
挑选 1 个提交。所以我做了
$ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad
Finished one cherry-pick.
但是当我执行git status
和gitx
时,我在git历史记录中看不到我的提交be530cec7748e037c665bd5a585e6d9ce11bc8ad
。
如何在 dev
分支中查看我的提交?
I have 2 branches, master
and dev
.
I am on dev
branch and I want to cherry-pick 1 commit from master
to dev
. So I did
$ git cherry-pick be530cec7748e037c665bd5a585e6d9ce11bc8ad
Finished one cherry-pick.
But when I do git status
and gitx
, I don't see my commit be530cec7748e037c665bd5a585e6d9ce11bc8ad
in git history.
How can I see my commit in the dev
branch?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
当您选择时,它会使用新的 SHA 创建一个新的提交。如果您这样做:
那么至少您会从附加到新提交的原始提交中获得提交消息,以及原始 SHA,这对于跟踪cherry-picks非常有用。
When you cherry-pick, it creates a new commit with a new SHA. If you do:
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.
如果您是 IntelliJ 用户,这非常简单。
在这里,我挑选从
master
分支到give-me-commit-branch
的提交。请注意下图中的几点:give-me-a-commit-branch
。由标签图标表示。master
分支是提交的来源。这易于使用且透明。
If you're an IntelliJ user, it's pretty simple.
Here, I am cherry-picking a commit from
master
branch togive-me-commit-branch
. Note a few points in the below pic:give-me-a-commit-branch
. Denoted by tag icon.master
branch whose commit logs are displayed on the right side is the source of the commit.This is easy-to-use and transparent.
如果您使用的是 Visual Studio Code,则可以使用 Gitlens 扩展让樱桃采摘变得更简单。
您还可以使用搜索和比较功能来搜索具体提交并右键单击以查看“Cherry Pick Commit...”选项。
请参阅下面的屏幕截图:
If you're using Visual Studio Code, you can use the Gitlens extension to make cherry picking simpler.
You can also use Search and compare feature to search for specific commit and right-click to see the "Cherry Pick Commit..." option.
Refer below screenshot: