I just read amending a single file in a past commit in git but unfortunately the accepted solution \'reorders\' the commits, which is not what I want. So here\'s my question
You can create a fixup for a particular file by using this alias.
[alias]
...
# fixup for a file, using the commit where it was last modified
fixup-file = "!sh -c '\
[ $(git diff --numstat $1 | wc -l) -eq 1 ] && git add $1 && \
[ $(git diff --cached --numstat $1 | wc -l) -eq 1 ] || (echo No changes staged. ; exit 1) && \
COMMIT=$(git log -n 1 --pretty=format:"%H" $1) && \
git commit --fixup=$COMMIT && \
git rebase -i --autosquash $COMMIT~1' -"
If you have made some changes in myfile.txt but you don't want to put them in a new commit, git fixup-file myfile.txt will create a fixup! for the commit where myfile.txt was last modified, and then it will rebase --autosquash.