git rebase
is your friend.
One easy way to accomplish this is to use git branch
to produce three identical branches (Develop, NewBranchTwo, NewBranchThree), which you then edit down using
git rebase --interactive C1
...replacing C1 with the commit's hash or other ref. In interactive mode, git will first pop open a text editor where it shows you the entire history, and where commits wil be applied in order from top to bottom according to any deletions or reorderings you make in the editor. You could easily remove C3 through C5 for Develop, and make corresponding edits to the other branches.
You can also skip the interactive mode and use git reset
and git rebase --onto
to move C6 onto C2 and name that Develop, and the same with C3 onto your upstream head and C5 onto that (etc). Without knowing the actual hashes or parent of C1, I'll leave the actual commands there to the git rebase documentation.
(You put git-revert in your tags, but if you're trying to divide commits, git revert
won't help: it records new commits that undo existing commits without erasing them. If you want history to look as it does, rather than C1 C2 C3 C4 C5 C6 rev-C5 rev-C4 rev-C3
, you'll need to rebase or otherwise edit history.)
As you're probably aware, any time you're adjusting commits that have already happened, you change their hashes and may make it difficult for anyone who has branched already. Hopefully you haven't pushed your remote Develop branch yet!