How to use my changes for merge in git?

大城市里の小女人 提交于 2019-12-06 06:21:37

问题


How do I force "my changes" when merging in git? Someone put all bin directories in git and now I have a terrible merge conflict :(

Now it says the following:

When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort".

I do NOT want to merge, i just want to delete all those files using my changes.

EDIT: Most of the files was successfully merged, either through automatic merge or because there was no conflict. However quite a few still exist like the following one.

warning: Cannot merge binary files: src/reports/obj/Debug/TempPE/GroupMailDS.Designer.cs.dll (HEAD vs. added gitignore)


回答1:


I'm not 100% confident about this, but I think this is a good case for this:

git merge otherbranch -s recursive -X ours

That command attempts to merge the topic branch into your checked out branch using the recursive strategy. The -X ours option is a subset of the recursive strategy that automatically resolves conflicts by making the assumption that your currently checked out branch is authoritative.




回答2:


You can:

  • git rm the obj directory (which contains all those binary files and shouldn't have been committed in the first place)
  • add a .gitignore directive to make sure any future obj directory won't appear in the git status (and won't be added)
  • git push that new tree, helping to propagate the fact that 'obj' directory should disappear from other Git repos as well (hence triggering no merge at all).

If you can have the consent of all the other participants, you could:

  • remove permanently that directory from your Git repo
  • git push -f (forced push) to a "central" git repo from which the other developers could fetch and reset their own branches.

But since it involves replacing published history by a new one, it should be done only if the other users agree.




回答3:


I guess you can just replace their binaries with yours (since no merge is really possible) or just git rm the unwanted binaries. After you have done, just git rebase --continue



来源:https://stackoverflow.com/questions/3100167/how-to-use-my-changes-for-merge-in-git

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