我可以从不同分支中挑选多个提交吗?

问题描述 投票:0回答:2

我有3个分支,m是master的头,而gh是单个提交分支。我目前无法进行变基或合并。我想要的是在母版的顶部选择gh中的更改,而无需提交它们,而只是取消暂存它们。这3个之间没有冲突。但是,我只能选择gh。当我尝试选择另一个时,选择失败:

error: your local changes would be overwritten by cherry-pick.
hint: commit your changes or stash them to proceed.
fatal: cherry-pick failed

是否可以执行this

git cherry-pick
2个回答
0
投票

您应在尝试挑选某些东西的分支上提交更改。没有活动的更改应该存在,然后您将可以从任何分支中挑选任意数量的提交]


0
投票

首先,请查看您的git status,某些文件已更改。比起您可以使用git stash隐藏隐藏的更改,重置或提交更改。

如果您想将gh的提交合并到m中,则比这样做

1)

git checkout m
git cherry-pick <commit_from_g>
git cherry-pick <commit_from_h>
git rebase -i #squash last to commits into one

2)

git rebase m h
git rebase h g
git checkout g
git rebase -i #squash last to commits into one
© www.soinside.com 2019 - 2024. All rights reserved.