如何将每个过去的提交置于其自己的单独分支上?

问题描述 投票:-1回答:1

所以我想从这种状态出发:

A - B - C - D - E

至此状态:

A (feature/1 branch)
B (feature/2 branch)
C (feature/3 branch)
D (feature/4 branch)
E * master

我该如何做?预先感谢。

git git-branch git-commit git-commands
1个回答
1
投票

P成为A的父项。据我了解,您希望每个提交都将P作为其父级。对于每个提交,在此处创建一个分支,然后通过将其从其当前父级“剪切”下来并“粘贴”至P

来重新建立它的基础。
git checkout -b feature/2 B
git rebase HEAD~1 --onto P

git checkout -b feature/3 C
git rebase HEAD~1 --onto P

依此类推。 A已经具有P作为其父级,因此您只需要git branch feature/1 A来创建分支。

© www.soinside.com 2019 - 2024. All rights reserved.