If your mistakes are such that master currently looks like:
A->B->C->D
and you just want to move C
and D
to a new branch, it's pretty easy:
$ git checkout master # move to D
$ git branch new-branch # create new branch at D
$ git reset B-sha1 # reset master to B
$ git checkout new-branch # continue working on new-branch
Depending on what changes are introduced by C
and D
, this may not work cleanly. For example, if C
introduces a new file, git may not let you do the checkout of new-branch for fear of overwriting the file. (When master is checked out at B
, git thinks the file is untracked.) You could add a git clean -xdf
after the reset, or do reset --hard
depending on the circumstances.