C. S. Duke C. S. Duke - 1 month ago 5
Git Question

How do I add a file to the last local commit?

Sometimes I forget to add some files before commiting. With Mercurial I fix it this way:

  1. hg qinit

  2. Convert commit to patch

  3. Update patch

  4. Convert patch to commit

Can I do anything like this with Git?


You are basically trying to change your last commit in Git. This is possible and quite simple.

git commit --amend is used for this purpose.

The following page gives a detailed example.