重新设置单个Git提交 [英] Rebase a single Git commit

查看:85
本文介绍了重新设置单个Git提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以将单个提交从一个分支重新部署到另一个分支?

Is there a way to rebase a single commit from a branch onto another branch?

我有这个分支结构:

-- -- -- -- -- (Master)
            \
              -- -- -- -- -- XX (Feature-branch)

我要做的就是将Feature-branch的最后一次提交重新建立到master上,并回滚Feature-branch一个提交.

All I want to do is to rebase the last commit of Feature-branch onto master and rollback Feature-branch one commit.

-- -- -- -- -- XX (Master)
            \
              -- -- -- -- -- (Feature-branch)

我该怎么做?

推荐答案

您可以选择XX来熟练掌握XX.

You can cherry-pick XX to master.

git checkout master
git cherry-pick <commit ID of XX>

并使用git reset删除功能分支中的最后一个提交.

And remove the last commit from the feature branch with git reset.

git checkout Feature-branch
git reset --hard HEAD^

这篇关于重新设置单个Git提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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