Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 我可以从不同的分支选择多个提交吗?_Git_Cherry Pick - Fatal编程技术网

Git 我可以从不同的分支选择多个提交吗?

Git 我可以从不同的分支选择多个提交吗?,git,cherry-pick,Git,Cherry Pick,我有3个分支,m是主机的负责人,而g和h是单提交分支。此时我无法进行重基或合并。我要做的是在母版的基础上挑选g和h中的更改,而不提交它们,只是让它们不老化。这三者之间没有冲突。但是,我只能选择g或h。当我尝试以樱桃色选择另一个时,樱桃色选择失败: error: your local changes would be overwritten by cherry-pick. hint: commit your changes or stash them to proceed. fatal: cher

我有3个分支,
m
是主机的负责人,而
g
h
是单提交分支。此时我无法进行重基或合并。我要做的是在母版的基础上挑选
g
h
中的更改,而不提交它们,只是让它们不老化。这三者之间没有冲突。但是,我只能选择
g
h
。当我尝试以樱桃色选择另一个时,樱桃色选择失败:

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

可以这样做吗?

您应该在尝试选择内容的分支上提交更改。不应存在任何活动更改,然后您将能够从任何分支中选择任意数量的提交

首先,查看您的
git状态
,工作目录中的某些文件已更改或索引不清晰。您可以使用
git stash
隐藏隐藏中的更改,或者重置或提交更改

如果要将
g
h
分支的提交合并到
m
中,请执行此操作

(一)


你可以把它们藏起来,而不是提交。”我想要的是在master的基础上切利地挑选g和h中的变化,而不是提交它们,只是让它们不显示“自相矛盾”。摘樱桃是一种承诺。你必须在开始之前承诺。您可以提交,然后cherry pick g,然后cherry pick h,解决任何合并冲突,然后重置索引。但不清楚你为什么要这么做。这是好的,不是坏的。
git checkout m
git cherry-pick <commit_from_g>
git cherry-pick <commit_from_h>
git rebase -i #squash last to commits into one
git rebase m h
git rebase h g
git checkout g
git rebase -i #squash last to commits into one