In some case, I want only to undo the changes on specific files on the first commit to add them to a second commit and have a cleaner git log.
In this case, what I do is the following:
git checkout HEAD~1 <path_to_file_to_put_in_different_commit>
git add -u
git commit --amend --no-edit
git checkout HEAD@{1} <path_to_file_to_put_in_different_commit>
git commit -m "This is the new commit"
Of course, this works well even in the middle of a rebase -i
with an edit option on the commit to split.