4 ms·
Probably to take a series of commits and decide "this one goes on branch A, this one on branch B", e.g. if you intermingled fixing bug A and B in the same branc
by rmunn 3mo ago
Probably to take a series of commits and decide "this one goes on branch A, this one on branch B", e.g. if you intermingled fixing bug A and B in the same branch, you could more easily go through and assign each commit to a new branch.
The existing workflow for that would be (there are several possible workflows, but this is what I would do):
git checkout intermingled-branch
git branch bugfix-A
git branch bugfix-B
git checkout bugfix-A
git rebase -i
# Edit the file, keep commits that fix bug A, drop commits that fix bug B
git push origin bugfix-A:bugfix-A
git checkout bugfix-B
git rebase -i
# Edit the file, keep commits that fix bug B, drop commits that fix bug A
git push origin bugfix-B:bugfix-B
- LtWorf 3mo agoSo git cherry-pick?
- WorldMaker 3mo agoFun fact, you can also automate more of that existing workflow with the rebase interactive TODO list. Roughly something like: pick $ACOMMIT1 edit $ABMIXEDCOMMIT # split out A parts pick $ACOMMIT2 exec make test # test everything compiles update-ref bugfix/A exec git switch --detach main # new branch point pick $BCOMMIT1 edit $ABMIXEDCOMMIT # split out B parts pick $BCOMMIT2 exec make test update-ref bugfix/B exec git merge bugfix/A pick $FOLLOWUPCOMMIT exec make test update-ref intermingled-branch # or bugfix/C It's been a while since I've attempted a rebase TODO list that wild, so I may have forgotten something, but rebase interactive is pretty wild what it will let you try to automate.