Having the following trivial commits
# define function in one file
echo "function foo () {}" > a
git add a
git commit -m "1st commit"
# call the function in different file
echo "foo()" > b
git add b
git commit -m "2nd commit"
# rename foo to bar in both files
echo "function bar () {}" > a
echo "bar()" > b
git commit -am "fixup"
is it possible to automatically split the fixup commit to update both previous commits?
I'm thinking that if the fixup commit only changes lines that were changed in the original commits, it should indeed be possible to precisely algorithmically split the fixup commit. Is that the case? If so, does git support it?
I know this can be done with multiple rebases and manually splitting the fixup commit, but that is not what I'm after.
Clarification: Imagine working on a feature branch. You have numerous commits. Upon code review it was found that for example method foo
should rather be named method bar
. Now before pushing to the upstream I'd rather not just change all instances of it add a new commit, but split the last commit and apply it's parts to the appropriate prior commits.