Pushed to wrong repo - revert a push

So in a recent push, we found a major booboo. Changes were pushed to the original repo AND the fork.

Thus a year's worth of commits all sent to the wrong place... all left in their original chronological order.... which isn't much help to revert.

The bitbucket dashboard shows "28 coommits pushed to xyz"... however when I click that link, it just shows /commits/all .

Is there a way to show all commits from a given push? Or a way to revert a push?

1 answer

It is not possible to show all commits from a given push, once the push is complete.

Reverting the push: In your local clone, reset the branch(es) to the last good state and (force) push them to the server. This will make all commits after the reset point(s) disappear from the server. If there are further commits on top of the bad ones, you will need to re-do them afterwards.

Thanks for the response Balazs

The problem is some of those commits occured prior to the previous state. So if I were to reset to the previous commit, it would still be wrong.

You need to reset to the last commit where everything was OK, which apparently is not the previous one. If this makes some "good" commits disappear as well, you need to redo them afterwards. (You can take a "backup" of the current state of the branch by renaming it to something else and then checking out the original one with the original name again. Afterwards, you can cherry pick from the backup branch to the one you are repairing.)

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published May 30, 2018 in Sourcetree

Tip from the team: configuring Git or Mercurial in Sourcetree

Supported Platforms macOS Windows To make using Sourcetree as simple yet powerful as possible we embed (bundle) dependencies such as Git, Git LFS, and Mercurial. We strive to keep these...

434 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you