git pull broke something - how to go back to previous working commit and merge the remote changes in again?

人走茶凉 提交于 2021-01-01 08:11:16

问题


I commited a new feature locally, pulled from remote and got merge conflicts. After resolving them, my feature stopped working (seems like I made an error).

My idea was to go back to my commit and somehow repeat the merge. I checked out my commit, made a new branch, checked out master and tried to merge the new branch into master. This didn't work because "Everything is up to date".

How do I best handle this if I don't want to fix the error by looking through the code by hand?

/edit: I accepted the correct answer to the question but it turns out that my problem has a different origin than assumed above. I asked a follow-up question here.


回答1:


If you do the checkout of your commit after the first merge to master, you will get an "Everything is up to date" when merging from master.

m--m--m
       \
 f--f1--F
      \
       newBranch: master is already merged

You need, as commented, to reset --hard to f1, and retry the merge.
As long as you don't push, you can reset/retry as many times as you need.



来源:https://stackoverflow.com/questions/65384476/git-pull-broke-something-how-to-go-back-to-previous-working-commit-and-merge-t

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