我可以孤立一个现有的分支吗? [英] Can I orphan an existing branch?
本文介绍了我可以孤立一个现有的分支吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在回购中创建了几个分支,并且意识到(对它们进行各种更改之后)为时已晚,我应该把它们变成孤儿。
I've created a few branches in a repo, and realized too late (after making various changes to them) that I should have made them orphans. Is it possible to orphan them after the fact?
推荐答案
我确定有可能。也许有一种更有效的方法,但似乎可行:
I'm sure it's possible. There might be a more efficient way, but this seems like it would work:
- 在旧分支中查找第一个提交,并调用它
第一个
。 -
git checkout --orphan new-branch $ FIRST
-
git checkout old-branch
-
git rebase --onto新分支$ FIRST
- Find the first commit in your old branch, and call it
FIRST
. git checkout --orphan new-branch $FIRST
git checkout old-branch
git rebase --onto new-branch $FIRST
现在,您的原始分支位于 old-分支
和位于 new-branch
的新的孤立分支。您可以根据需要删除或重命名 old-branch
,然后将 new-branch
重命名为旧分支
。
Now you have the original branch at old-branch
and a new, orphaned branch at new-branch
. You can, if you like, either delete or rename old-branch
, and rename new-branch
to old-branch
.
这篇关于我可以孤立一个现有的分支吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文