The solutions here will work but you will lose other changes in the same commit. If you don't want to lose the other changes in the same commit, and you didn't push the commit yet, you have to change HEAD back to a previous commit, add the changed file and amend:
First find which commit you would like to return to:
$ git log --oneline
Then, it's needed to checkout another branch because you cannot change the HEAD in the active branch:
$ git checkout master
Then, change the head of the branch to an older commit:
$ git branch -f <branch_name> <commit_id>
Then, add the changed file to current commit:
$ git add <filename>
Then, amend the change into current commit:
$ git commit --amend --no-edit
That multi-step solution worked out for me to not lose changes and add new changes to a previous commit.