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.
巴扎黑2017-05-02 09:49:43
If you merge locally, you can go through the git reflog
查看你的历史操作,然后通过 git reset --hard HEAD@{n}
回退到 reflog 里面的第 n
step
Then, git push origin master -f
you can return the remote master to its previous state
In 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 master
The 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