git rebase一次提交 [英] git rebase a single commit

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

问题描述

有没有一种方法可以将一个分支单个提交到另一个分支?



所以我有

   -   -   -   -  - (主)
\
- - - - - XX(功能分支)

并且我想要做的就是将Feature-branch的最后一次提交重新分配到master和rollback Feature-branch一次提交。

   -   -   -   -   -  XX(主)
\
- - - - - (Feature-branch)

我该怎么做?

解决方案

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

  git checkout master 
git cherry-pick<提交ID为XX>

使用git reset从功能分支中删除最后一次提交。

  git checkout特性分支
git reset --hard HEAD ^


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

So I have

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

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

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

How do I do that?

解决方案

You can cherry-pick XX to master.

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

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

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

这篇关于git rebase一次提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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