Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace remote master branch with my local

Tags:

git

github

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.

like image 836
starscream_disco_party Avatar asked Jan 11 '23 03:01

starscream_disco_party


1 Answers

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.

like image 142
Jonah Avatar answered Jan 16 '23 00:01

Jonah