Git:如何重新定位到特定的提交? [英] Git: How to rebase to a specific commit?

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

问题描述

我想 rebase 到特定的提交,而不是另一个分支的 HEAD:

I'd like to rebase to a specific commit, not to a HEAD of the other branch:

A --- B --- C          master
 
  -- D                topic

A --- B --- C          master
       
        -- D          topic

代替

A --- B --- C          master
             
              -- D    topic

我怎样才能做到这一点?

How can I achieve that?

推荐答案

您可以通过在您喜欢的提交上创建一个临时分支,然后以简单的形式使用 rebase 来避免使用 --onto 参数:

You can avoid using the --onto parameter by making a temp branch on the commit you like and then use rebase in its simple form:

git branch temp master^
git checkout topic
git rebase temp
git branch -d temp

这篇关于Git:如何重新定位到特定的提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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