git cherry选择一系列包括合并在内的各种提交 [英] git cherry pick a range of sequently commits including merge

查看:83
本文介绍了git cherry选择一系列包括合并在内的各种提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


$ b

例如
$ b





在分支主文件上,我想挑选从d4fd8cad到开发
的HEAD的变更。

git cherry-pick d4fd8cad..develop


有一个错误信息



错误:提交885c9e07264ac6b5d3960 ...是一个合并,但没有-m选项。




致命:樱桃挑选失败



如何使用-m选项?

解决方案

在这种情况下,使用交互式rebase可能会更好。



将d4fd8cad..HEAD从分支开发应用到master ,您可以使用以下命令。



确保我们正在开发:

  git checkout开发

分支开发:

  git checkout -b develop-rebase 



对主人进行交互式重新分配。 -p选项让你保留合并提交。

  git rebase master -i -p 

在d4fd8cad之前删除所有提交的行。



保存rebase文件。



解决冲突,如果有的话。

现在你有一个看起来像你想让主分支看起来一样的分支。看看 gitk 来验证您是否想要。



现在我们所要做的就是将它合并到master 。如果这不是一个快进合并,那么可能发生了错误,所以我们添加--ff-only标志

  git checkout master 
git merge develop-rebase --ff-only


I can cherry pick a range of sequent commit .

for example

on branch master,I want to cherry-pick changes from d4fd8cad to HEAD of develop

git cherry-pick d4fd8cad..develop

There is an errorr

error: Commit 885c9e07264ac6b5d3960... is a merge but no -m option was given.

fatal: cherry-pick failed

how can I use the -m option ?

解决方案

In this case it might be better to use an interactive rebase.

To apply d4fd8cad..HEAD from branch develop to master, you can use the following command.

Make sure we are standing in develop:

git checkout develop

Branch out of develop:

git checkout -b develop-rebase

Do an interactive rebase on master. The -p option lets you keep the merge commits.

git rebase master -i -p

Delete all the lines with commits before d4fd8cad. Leaving you with the commits you wanted to cherrypick.

Save the rebase file.

Resolve conflicts, if any.

Now you have a branch that look exactly like you want your master branch to look. Take a look in gitk to verify if you want.

Now all we have to do is merge this into master. If this is not a fast-forward merge, something wrong has probably happened, so let's add the --ff-only flag

git checkout master
git merge develop-rebase --ff-only

这篇关于git cherry选择一系列包括合并在内的各种提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆