I've coded a feature spanning thousand of modified lines in a project, and now it all ended up in one big commit (I've squashed the work-in-progress commits). Now I'd like to split the changes into multiple commits for easier review/possibly multiple PRs.
Some files contain multiple changes that should end up in different commits, so I am looking for a WYSIWIG editor using three-pane view, that would allow me to move some lines to the intermediate commit while seeing the previous and future version (+ some manual changes). I use IntelliJ IDEA for the development, so I imagine something similar to conflict resolution dialog.
I could switch to different branch/tag the single-commit version and do Git->Compare with Branch (and grab the changes from there), but I am looking for something of more convenience.
While this could be marked as off-topic/opinionated, I believe that a neutral suggestion for a different workflow might be valuable.
For IntelliJ I use this workflow:
Alt + 9
Alt + E
🏷️!
→ Undo commit... alternatively execute git reset HEAD~1
in the terminal
Ctrl + K
to select and commit your changes with the according message. Repeat as often as necessary until all changes are committed.Not sure about a tool that lets you do this, but, as according to the git documentation you can split a commit using the builtin rebase
function. Something like:
git rebase -i
...
pick abc1234 the commit I wanna keep
edit 5904fjl THE COMMIT I WANT TO SPLIT
pick alkj022 my latest commit to keep
After that run git reset HEAD^
and you can manually break out your changes into commits. You can use the git add --patch
to more easily split your intra-file changes into commits. Or if your Intellij IDE has a good git GUI you can use that. The splitting, at least in my experience, has to be done from the command line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With