0

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?

jsageryd
  • 4,234
  • 21
  • 34
Abdur Rahaman
  • 197
  • 2
  • 12

3 Answers3

3

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

ErikMD
  • 13,377
  • 3
  • 35
  • 71
0

Use the push --force command to force push over the old commit.

git push --force example-branch

https://help.github.com/articles/changing-a-commit-message/

Yogi
  • 609
  • 1
  • 8
  • 21
-2

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
Mauricio Machado
  • 613
  • 1
  • 5
  • 14