Undo a git merge when it has been pushed

烈酒焚心 提交于 2019-12-12 02:49:21

问题


How can I undo a merge when I have already pushed to master after merge? Here are my steps:

  1. git add -A

  2. git commit -m "some message"

  3. git fetch origin master:master

  4. git rebase master (resolve merge conflicts)

  5. git push -f origin my local branch

I want to go back to the state where i was at step 2


回答1:


You force pushed, meaning you overwrote the changes on a remote. Your computer can't fix it; however, if there is another computer with a local copy before you force pushed, you can force push from that computer and overwrite your force push.

Git's push --force is destructive because it unconditionally overwrites the remote repository with whatever you have locally, possibly overwriting any changes that a team member has pushed in the meantime. - Atlaissan Git Resource

There are some cases where checking out to an old commit and then force pushing that might work, but I suspect that probably won't work in your case because you had to force push your changes.



来源:https://stackoverflow.com/questions/35532077/undo-a-git-merge-when-it-has-been-pushed

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!