git远程库回退问题

本人用flask已经在heroku部署完成
我需要修改代码重新提交,误将路径切换另外一个文件夹,将此错误文件夹的master分支提交到远程库了
命令为git push heroku master
而我切换到正确的代码文件夹再提交,提示

 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to     'https://git.heroku.com/hulumei.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.  

如果用git pull,则把远程仓库的错误代码和本地代码合并了,然后我在用git reset --hard 版本号命令回退到正确的节点,再提交到远程库,还是提示上面的信息
求大神解答?拜谢

阅读 5.3k
2 个回答

如果你能确认你当前分支的代码是正确的。

git push heroku master --force

撤销远程记录

  • git reset --hard HEAD~1 #撤销一条记录

  • git push -f heroku HEAD:master #同步到远程仓库

git 撤销远程记录

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题