Getting merged code “right” with Git

守給你的承諾、 提交于 2019-12-04 10:33:12
VonC

Considering you haven't pushed your faulty commit yet, you can safely reset your HEAD to the commit before:

git reset --hard HEAD^

(Make sure you don't have work in progress, like private files or files added to the index, because both the working tree and the index would be reset to the HEAD^ state)

This is what the answer you mention suggests.

But after that, you need to make sure your coworkers' changes are taken during the merge your are about to do again.
See if a theirs "merge strategy option" works better.

git checkout yourBranch
git merge -X theirs theirBranch

However, I suspect it would work only for solving conflicts (concurrent modifications in a file).
If you have made more recent changes, those would still be in the resulting merged HEAD.

If that is so, try following the recipe in this answer, which forces a merge to your branch, and then reset yourBranch to theirBranch, before moving HEAD to the merged commit done before.
Then end result should look like what you are after.

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