用我的本地替换远程主分支

sta*_*rty 3 git github

我一直在做一个项目,事情变得草率.我要做reset一个稳定的提交,但是当我试着push告诉"当前的分支是在它的远程对手后面"(显然).Git让我执行的唯一选择是git pull.当我尝试的时候,我又回到了新的,草率的提交,这些提交不起作用,我不想要.

我做了一个不同的分支调用stable并运行reset --hard到稳定提交,然后尝试以下方法:

$ 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.
Run Code Online (Sandbox Code Playgroud)

运行这些命令后,我的master分支仍然处于我想要摆脱的状态.

我想stable成为新人,master但我不确定现在该做什么.

Jon*_*nah 8

你正在寻找力推(见--force选项).请注意,因为您通常不希望更改与其他开发人员共享的远程分支的历史记录.