A similar question, How to cherry-pick multiple commits, assumes that the commits are consecutive.
I have a module that I downloaded as a tarball. I've included it in my main project's git repo and made changes to it. These changes are interspersed with other commits for the main project.
I've realized the error of my ways and want to replace the module with a git submodule. I could just add the current state, but I want to keep my git history.
How can I move each individual commit into my new repo?
I think I can do this with cherry-pick, but it's time-consuming. Here's what I have:
Setup my new repo with the main project as a remote (so I can cherry pick):
cd ~/snippets
git remote add main ~/.vim/
git fetch main
I can see the relevant commits in the main project with git log ~/.vim/snippets
I can make a script to cherry pick with
cd ~/.vim/snippets
git log --oneline --reverse --format="format:git cherry-pick %h #%s" .
But if I run the script, there are merge conflicts. After I resolve a merge and commit, I need to remove the successful bits from my cherry pick script and run it again. I'd like to do this automatically, like git rebase.