from sympy.core.exprtools import factor_terms

This is my last comment...I defer to @asmeurer for the final ok wrt ode requirements. And raoulb was wanting a better citation.

Once you've made your last commit then (let's say there are 6 of them) do

git rebase HEAD~5  # one less than total commits
git add -u; git commit --amend

And make any edits to the commit message and push with -f.