我如何在最后3个提交之前创建新分支并将最后3个提交移动到新分支?(我在gitlab中推送我的所有提交)



如何在最后3次提交之前创建新分支并将最后3次提交移动到新分支中?来自:

a -> b ->c -> d-> e -> f (master)

:

a-> b->c(master)

d-> e-> -> f(new_branch)

如果您是repo的唯一所有者,而不需要与同事保存共享的历史记录:

当前指向fmaster分支:

# create your new branch
git branch new_branch
# reset master where it should
git reset --hard c
# then push the rewritten version of master to gitlab (assuming "origin" here)
git push -f origin master

如果,另一方面,你正在共享这个repo,打破master的历史可能是避免的(与你的团队讨论)。

相关内容

最新更新