4 ms·
I want to be able to split a single commit into multiple commits. I sometimes mix clean-up changes with core logic changes in a single commit. That is something
by Pet_Ant 2y ago
I want to be able to split a single commit into multiple commits. I sometimes mix clean-up changes with core logic changes in a single commit. That is something I'd pay for. To be able to just drag'n'drop the files from commit to commit. Especially if I could split changes within a file between commits. Something more powerful than the partial commits of Intellij.
- pimlottc 2y agoYou can do this, via the command line at least, using `git rebase`: https://stackoverflow.com/a/6217314 https://stackoverflow.com/a/6217314
- 3np 2y agoThe way I do this, I duplicate each entry for the commit-under-splitting N+1 times when splitting it into N parts. Then for each, I manually edit the commit to its desired state during the interactive rebase, and then the last one should be empty (or only consist of leftover changes that should be dropped).
- WolfeReader 2y ago(Assuming you haven't already pushed to remote) Create a new branch, called "preSplit", at the commit where you want to split. Take your actual branch and reset it to one commit prior. Grab the first set of changes you want from "preSplit" and commit. Repeat until each distinct set of changes has its own commit. If needed, rebase commits after "preSplit" onto your current branch. I'll do it for you, for a modest fee!
- corytheboyd 2y agoLazygit patches are a great way to do this. You can interactively select lines from commits to “pull out” making them easy to form new commits with. Takes some getting used to, but it is the exact flow you are talking about. https://github.com/jesseduffield/lazygit?tab=readme-ov-file#rebase-magic-custom-patches https://github.com/jesseduffield/lazygit?tab=readme-ov-file#... Oh you edited to say drag and drop. Lazygit is a TUI and patches are very much keyboard driven. Still worth thinking about? It’s free!
- Cykelero 2y agoI'm actually working on adding this to Retcon right now! It's one of the biggest feature requests. So far the implementation goes like this: you enter Edit mode on a commit; you unstage some lines; and you confirm. The lines are yanked from the commit, and added to a new commit that you just have to title. I just use it on the Retcon repo and it's real cool to have.
- Zambyte 2y agoYou may find Jujutsu appealing. Particularly the jj split subcommand. https://martinvonz.github.io/jj/latest/cli-reference/#jj-split https://martinvonz.github.io/jj/latest/cli-reference/#jj-spl...
- rurban 2y agoI do this constantly via the command-line in 5s. git fp, patch, git rebase