Use git rebase
. Specifically:
git stash
to store the changes you want to add.git rebase -i HEAD~10
(or however many commits back you want to see).(a0865...)
for edit by changing the word pick
at the start of the line into edit
. Don't delete the other lines as that would delete the commits.git stash pop
git add <file>
.git commit --amend --no-edit
.git rebase --continue
which will rewrite the rest of your commits against the new one.