I commited my file and pushed to GitHub. But I forgot to add my HTML file. So I used git commit --amend to amend my commit. But now how can I resolve my mistake on GitHub?
 
    
    - 4,234
- 21
- 34
 
    
    - 197
- 2
- 12
- 
                    you can try to squash commit `git reset --soft HEAD~1` than `add` all files and commit again, this will override your last commit – shahaf Apr 07 '18 at 07:11
- 
                    git push --force-with-lease – JB Nizet Apr 07 '18 at 09:33
- 
                    @JB Nizet sorry I did not see your comment before posting my answer... – ErikMD Apr 07 '18 at 13:52
3 Answers
As pointed out by @Yoginth, you might do git push --force, but it is better (because safer) to do git push --force-with-lease instead.
The corresponding syntax is described in this handy list of git tips:
git push --force-with-lease <remote-name> <branch-name>
To be more precise, git push --force-with-lease will refuse to force-push if the remote branch (say, branch master in repo origin) has commits that are unknown in local branch origin/master
 
    
    - 13,377
- 3
- 35
- 71
Use the push --force command to force push over the old commit.
git push --force example-branch
 
    
    - 609
- 1
- 8
- 21
All that said, have in mind that amending a commits previously pushed is a bad practice (bad bad), and it is only safe to do in the case of the branch you're pushing is only yours and not a shared one.
If someone else pulls from that branch, it could lead to conflicts, and lots of unexpected situations such as:
- Conflicted merges
- Overritten changes
- Headache
- Joint pain
- Global warming
 
    
    - 613
- 1
- 5
- 14