-1

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
  • 3,682
  • 18
  • 32
Abdur Rahaman
  • 125
  • 1
  • 12

3 Answers3

1

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
  • 10,416
  • 2
  • 24
  • 55
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
  • 597
  • 1
  • 6
  • 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
  • 615
  • 1
  • 5
  • 14