如何在git中将提交应用于当前头部? [英] How to apply diff between commits to current head in git?

查看:126
本文介绍了如何在git中将提交应用于当前头部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在参与的项目上正在研究一些主题分支。我通常在提出请求前重新分配分支。但是,这一次,由于主人的变化,重组是一个很大的痛苦。很多冲突,更糟糕的是,在手动合并提交之后,这些提交看起来很丑陋,并且没有任何意义。我肯定会更喜欢在我的分支的头部和两个分支上的最新提交之间获得差异,然后将这个差异应用到主人的头上,最后用 git add -p 。所以我的问题是:如何实现它?一种可能性是将主人合并到我的主题分支中,但是有没有更优雅的解决方案?我相信是。



感谢您的帮助。


$ b

编辑 p>

一个文件已经在master分支上移动,我的提交正在修改这个文件(使用它的旧名称)。

解决方案

使用 git cherry-pick --no-commit< commit> ...

然后你会得到所有在你的分支上面应用的提交更改,你可以在闲暇时进行提交。


I was working on some topic branch on project I participate in. I normally rebase my branches before making a pull request. This time however, due to changes in master, rebasing is a big pain. Lot of conflicts and, what's worse, after manual merging commits look just ugly and loose their point. I would definitely prefer to obtain diff between my branch's head and latest commit present on both branches, then apply this diff to master's head and finally create brand new shiny commits with git add -p. So my question is: how to achieve it? One possibility would be to simply merge master into my topic branch, but is there a more elegant solution? I believe yes.

Thanks for your help.

EDIT:

One file has been moved on master branch and my commits are altering this file (using it's old name).

解决方案

Use git cherry-pick --no-commit <commit>...

Then you will get all the changes in the listed commits applied on the top of your branch, and you can commit at your leisure.

这篇关于如何在git中将提交应用于当前头部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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