[英]Git: Put last 3 commits into branch, reset master
I'm trying to perform some git surgery here. 我正在尝试执行一些git手术。 My series of commits currently looks like this:
我的一系列提交当前看起来像这样:
A->B->C->D->E->F
and I want to transform it so that it looks like this (last commit in master is C
): 我想对其进行转换,使其看起来像这样(master中的最后一个提交是
C
):
A->B->C
and 和
D->E->F
live in a branch off of commit C
D->E->F
位于提交C
的分支中
How might I do this? 我该怎么办?
Simply create a new branch from your current master: 只需从您当前的母版创建一个新分支:
git checkout master
git checkout -b newBranch
git push -u origin newBranch
A-B-C-D-E-F (master, NewBranch)
Then reset master (making sure you don't have any work in progress) 然后重置主机(确保您没有正在进行的任何工作)
git checkout master
git reset --hard C
A-B-C (master)
\
D-E-F (newBranch)
You will need to git push --force origin master
, so make sure you are the only one working on it. 您将需要
git push --force origin master
,因此请确保您是唯一从事此工作的人。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.