As mentioned, I merged the unfinished code from the branch to master, and git pushed it to github. Then I continued to improve the code on dev, and then when I wanted to withdraw the merge, I found that after withdrawing the local merge, it could not be When I pushed it to github, it showed a conflict. I don’t know why.
If you merge locally, you can go through the
git reflog
查看你的历史操作,然后通过git reset --hard HEAD@{n}
回退到 reflog 里面的第n
stepThen,
git push origin master -f
you can return the remote master to its previous stateIn fact, since you merge, a merge commit will be generated. You can also roll back locally
git checkout master
, 这时候你本地的 master 也应该是最新的。先git log
看下历史记录,然后根据 commit hash,git reset --hard xxxxxx
first.Then, similarly,
git push origin master -f
you can update the remote masterThe two methods are the same, because you deleted a commit, and this commit exists remotely. At this time, the historical information of two hundred years is inconsistent, so you cannot directly
git push origin master
除非你在这个 commit 之后新加了一个 commit,手动修改代码,回退到 merge 之前的状态,这样你不需要
-f
,可以直接git push origin master
update