4

I've been working on a project and things got sloppy. I've reset to a stable commit, but when I try to push I'm told "the current branch is behind its remote counterpart" (obviously). The only option that Git gives me to perform is git pull. When I try that I'm back to the newer, sloppy commits that don't work and I don't want.

I made a different branch called stable and ran reset --hard to the stable commit and then tried the following:

$ git checkout stable
  # =>  Switched to branch 'stable'

$ git merge -s ours master
  # =>  Already up-to-date.

$ git checkout master
  # =>  Switched to branch 'master'
  # =>  Your branch is behind 'origin/master' by 9 commits, and can be fast-forwarded (use "git pull" to update your local branch)

$ git merge stable
  # => Already up-to-date.

After running these commands my master branch is still in the state that I want to get rid of.

I'd like to have stable be the new master but am unsure what to do now.

starscream_disco_party
  • 2,816
  • 5
  • 26
  • 42

1 Answers1

9

You're looking for a force push (see the --force option). Just have a care with that as you probably do not normally want to change the history of a remote branch shared with other developers.

Jonah
  • 17,918
  • 1
  • 43
  • 70