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

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

问题描述

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

to

  A --- B --- C master 
\
\- - D话题

而不是

<$ p $ A $ B code $ B $ C $ $ $ $ $ $ $ $ $ $ $ $ $ p>

我该如何做到这一点?

通过在你喜欢的提交上创建一个临时分支,然后在这个简单的表单中使用rebase:

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


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

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

to

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

instead of

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

How can I achieve that?

解决方案

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

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

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

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