How to delete latest commit on remote branch?

Keywords: git github

Question: 

I pushed some code to a remote branch, but I quickly found a bug.

I wanted to 'un-commit", so I ran

git reset hard~~ (extra tilde was by accident)

I probably messed up because after I fixed the bug I commited and pushed, but when I try to push I get an error.

running

git status

shows that "my branch and the remote branch have diverged, and have 1 and 2 different commits each"

I think this is what it looks like now:

o ---- o ---- A ---- B -- D  origin/master (2 commits ahead of A)
               \
                C  master (my work (1 commit ahead of A)

How do I change my repository so that it looks like

o ---- o ---- A ---- C

Answers: