Git twists my brain. But I think I'm halfway there with this problem.
I committed (twice) and pushed to GitHub, but the first commit contained two files that should not have been included. So I have done the following...
git reset --hard HEAD~2
This brought the HEAD back to the first commit with the extra files.
HEAD is now at 1979096c2
Now, if I amend, commit (and force push) again with ONLY the two files that were needed, does this correct the commit on GitHub?
To be more clear... the initial (wrong) commit contained 4 files. I want to amend it to only have 2 files. Am I on the right track?
Instead of doing a hard reset, you can also do a git revert.
git revert <commit_id>
Use git log to refer to the commit id you want to revert.