I have split a lot of work with interactive rebasing. I'm excited to try `git history split` and to have learned about it here. But the stylistic flourish makes it seem like it's been a feature for years that people just haven't moved to instead of being something shiny and new to be excited about trying.
Splitting a Git Commit
21–30 of 74 posts
Re: Splitting a Git Commit
#22Earlier quoted context omitted.
I think this is harsh criticism. It's because not many people use SO any more. One of SO's selling points was that outdated answers get replaced with the more modern, better ones - and it worked for many, many years.
... until they decided it was a good idea to train all power users to grief new users off the site.
Re: Splitting a Git Commit
#23That's good to know, I'd usually go about it in a roundabout way: soft reset the commit then git add --patch to stage the hunks to split it into multiple commits.
Add to that, it's patch functionality isn't as robust as `git add --patch`. For example, you cannot edit a hunk, so if you intended to tease out atomic changes, you won't be able to.
Re: Splitting a Git Commit
#24jj split --interactive {ref}
Re: Splitting a Git Commit
#25Earlier quoted context omitted.
I do the same, but use `git gui` to select the changes.
Which gui? I’m on Mac and somehow I could never really be happy with gui‘s for git. Gitkraken is the last I tried and I found it too much cluttering. Paid choices weren’t that great aswell either (yet)
I use this only for the aforementioned purpose.
Re: Splitting a Git Commit
#26I never thought about whether this was possible, but now that I know it is, I immediately see how useful it could be for my workflow.
I had a team that insisted on a linear history and was constantly rebasing things. This workflow strongly favors "just squash it all together" before a rebase to avoid re-resolving the same conflicts. This workflow often produces big patches that reviewers end up asking to be broken back up. This experience and a recommendation from my manager at the time made a good git GUI like sourcetree a daily driver for me. It'…
Re: Splitting a Git Commit
#27The bit that made this click for me: it works on any commit in history, not just HEAD. Mark the commit as edit in git rebase -i, then git reset HEAD^ to uncommit it while keeping the changes in the working tree, and rebuild the pieces from there. git add -p is the real workhorse for the rebuild: s splits a hunk into smaller ones, and e lets you hand-edit the hunk when the boundary doesn't fall on clean line breaks. S…
Re: Splitting a Git Commit
#28or use jj and stop worrying about git jj split --interactive {ref}
Re: Splitting a Git Commit
#29The bit that made this click for me: it works on any commit in history, not just HEAD. Mark the commit as edit in git rebase -i, then git reset HEAD^ to uncommit it while keeping the changes in the working tree, and rebuild the pieces from there. git add -p is the real workhorse for the rebuild: s splits a hunk into smaller ones, and e lets you hand-edit the hunk when the boundary doesn't fall on clean line breaks. S…
Re: Splitting a Git Commit
#30or use jj and stop worrying about git jj split --interactive {ref}