branch - How to partition a git commit in two, based on same parent? -
i'm on branch foo, parent a:
---a---foo
i want partition changes foo 2 branches, both based on a. believe can half job this:
git checkout -b halffoo git reset head~ # choose half stuff. git add -i git commit
that gives me:
---a---foo \ \-halffoo
i know how (git checkout -b otherhalffoo; git commit -a):
---a---foo \ \-halffoo \ \-otherhalffoo
but i'd this:
---a---foo |\ | \-halffoo \ \-otherhalffoo'
how can without having go through 'git add -i' (and selecting negative of chosen halffoo) again?
first, rewind previous commit, leaving in changes since. branch off , apply of changes. branch off original branch again, , apply rest of changes.
git branch original_tip_with_foo # if want reference foo commit git reset head~ git stash git branch branch_2 # we'll there in moment ... git checkout -b branch_1 git stash pop git add -p # ... add first set of changes, first branch ... git commit -m'first set of changes' git stash git checkout branch_2 git stash pop git add -p # ... add second set of changes ... git commit -m'second set of changes'
Comments
Post a Comment