[git] How to add a file to the last commit in git?

Sometimes after I did a commit, I found out that I left out a file which should also be included in the commit but actually not. What I often did was commit again.

git add the_left_out_file
git commit "include the file which should be added in the last commit"

I think it might not be a good idea to do so, what I want to do is just include the file without adding a commit. Something like this,

git add the_left_out_file
git add_staged_files_to_previous_commit

Is it possible?

This question is related to git

The answer is


If you didn't push the update in remote then the simple solution is remove last local commit using following command: git reset HEAD^. Then add all files and commit again.