樱桃挑选多个提交,而无需浏览每个git应用程序
我有分支 a ,有几次提交我需要挑选到分支 b 。 在第一个樱桃挑选中,我添加了我稍后在最后一个提交中删除的代码。
当我尝试使用 first_commit^.. last_commit 樱桃挑选它们时,它仍然会一个挑选提交一一 - 迫使我解决我在第一个提交中添加的代码之间的冲突,即使我真的不需要解决这些冲突 - 因为我在最后的提交中删除了此代码,无论如何我还是试图挑选挑选!
所以我的问题是:是否有一种方法可以挑选一系列提交,而无需一个一个(解决每个人的冲突) - ,但只有最终结果它们在代码上的更改(应用了所有提交后的更改之间的冲突(如果有)和代码的其余部分)。
ps 我无法将a纳入B中,因为它包含了我不想要的其他内容,而且我认为我也尝试重新打击以相似的结果。
谢谢!
I have branch A with a few commits I need to cherry-pick into branch B.
In the first cherry-picks I've added code that I've later removed in the last commits.
When I try to cherry pick them using first_commit^..last_commit it still cherry-picks the commits one by one - forcing me to solve conflicts between the code I added in the first commits and other developers code, even though I don't really need to solve these conflicts- as I've deleted this code in the last commits I'm trying to cherry-pick anyway!
So my question is: is there a way to cherry-pick a range of commits without going through them one by one (solving conflicts for each one of them)- but only the end result of their changes in code (solving conflicts, if any, between the changes after all the commits were applied and the rest of the code).
P.S. I cannot pull A into B as it contains other content I don't want, and I think I've also tried rebasing with similar results..
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种快速的方法可以是:您可以使用
git Merge -squash
来创建一个单一的挤压提交,而不是挑选一个单个委托的顺序。如果您想在最终结果中有一系列提交,那么您需要使用
cherry-pick
或rebase
重新命令,您可能必须解决根据提交的基础进行冲突。您可以尝试避免挑剔问题的提交:
如果您的起始历史记录如下:
您可以尝试运行
git cherry-pick x1..e
(所有提交最多e <
e < /code>,不包括
x1
),而不是git cherry-pick main..feature
(所有人都提交最多功能>功能
不包括main
main < /code>,但包括
x1
和x2
)[更新],从您的评论中,它似乎要编辑您的历史记录(例如:将一些现有的投入分为“零件”您想保留要丢弃的“ vs”零件)。有几种方法:
如果您能够负担得起一个单一提交中的所有开发人员,这是一种方法:
&lt; sha&gt ;
在您的分支从主分支分配的位置,然后使用git reset -soft
:一旦您的结果仅包含您想要的端口
One quick way can be : instead of cherry-picking a sequence of individual commits you can create one single squashed commit using
git merge --squash
.If you want to have a sequence of commits in the end result, then you will need to use
cherry-pick
orrebase
to replay individual commits, and you may have to solve conflicts on a per commit basis.You can try to avoid cherry-picking the problematic commits :
if your starting history looks like this :
you can try to run
git cherry-pick x1..e
(all commits up toe
, excludingx1
) instead ofgit cherry-pick main..feature
(all commits up tofeature
excludingmain
, but includingx1
andx2
)[update] from your comment, it looks like you want to edit your history (e.g: split some existing commits into "parts you want to keep" vs "parts you want to discard"). There are several ways to do that :
if you can afford to squash all your devs in one single commit, here is one way :
<sha>
of the commit where your branch forked from master branch, and usegit reset --soft
:Once you have a result which contains only what you want to port, you can rebase or merge with target branch