0

I have a repository with a branch called "develop". Both origin and local are the same. Now I want to reset the last commit(s). I do:

git reset --hard HEAD^

This does what I want locally. How can I sync these changes to the remote repository? When I try to push now I get the error that my remote is X commits ahead.

git reset origin/develop --hard HEAD^

does not work.

Any ideas?

kidman01
  • 835
  • 5
  • 17
  • 32
  • 1
    Possible duplicate of [Force "git push" to overwrite remote files](https://stackoverflow.com/questions/10510462/force-git-push-to-overwrite-remote-files) – Liam Dec 12 '18 at 13:02

1 Answers1

2

type command like as below

1: git reset --hard  HEAD^
2: git push -f origin develop
MTTI
  • 391
  • 2
  • 10
Jay Suchak
  • 172
  • 1
  • 10
  • As a bonus, you might want to replace `-f` with `--force-with-lease` (see [why](https://git-scm.com/docs/git-push#git-push---force-with-leaseltrefnamegt)) – Romain Valeri Dec 12 '18 at 13:20