Git:将提交“移动到顶部” [英] Git: move a commit "on top"

查看:114
本文介绍了Git:将提交“移动到顶部”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

master 中说,我禁用了某个功能。
我在分支功能上使用该功能,所以我有一个特殊的提交 $ 该功能。
现在我想将我在功能中所做的更改合并到 master 中,但不要进行启用提交。就像

Let's say in master I have a feature disabled. I work on that feature on branch feature, so I have a special commit $ there that just enables that feature. Now I want to merge the changes I did in feature into master, but keep the enabling commit out. So it's like

main:    A--B--X--Y
feature: A--B--$--C--D

因此,我想通过移动 $ 在功能之上提交:

So let's say I want to do it, by moving the $ commit on top of feature:

new feature: A--B--C--D--$

我该怎么做?

推荐答案

git rebase -i B ,然后移动 $ 到编辑器中显示的列表末尾。它将从打开的文件的第一行开始。您也可以完全删除该行,这只会将该提交从分支机构的历史记录中删除。

git rebase -i B, and then move $ to the end of the list that shows up in your editor. It will start out as the first line in the file that opens. You could also just delete that line entirely, which will just drop that commit out of your branch's history.

这篇关于Git:将提交“移动到顶部”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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