1

I have accidentally pushed a large (complete project altering) commit to the wrong repo.

See screenshot.

Screenshot

I have locally reverted master to the "good" commit, but I would like to revert origin/master to the "good" commit and prevent the "accident" commit from being pulled by others on the project.

How is the easiest/cleanest way to accomplish this?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
bokuchan
  • 11
  • 1

1 Answers1

0

A git push -f origin master (in command-line) should be enough.

With SourceTree, after selecting "Enable Forse Push":

https://i.stack.imgur.com/lygMh.png

But:

prevent the "accident" commit from being pulled by others on the project

Others might already have pulled from your project: you will have to contact them, asking them to fetch and reset their own local master branch to the new origin/master.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • In the Sourcetree interface, just click Push and check the Force checkbox. – matt Jul 17 '21 at 18:58
  • 1
    @matt True, but you must select the option "Enable force push" first in the SourceTree settings: see https://stackoverflow.com/a/60294426/6309 – VonC Jul 17 '21 at 19:04
  • Ok, just trying to help OP stay in Sourcetree. – matt Jul 17 '21 at 19:06