git - confusion over terminology, “theirs” vs “mine”

梦想与她 提交于 2019-12-03 03:47:17

问题


I'm completely confused about what mine vs theirs means. In this specific case, I've got a feature branch where I just squashed about 80 commits via rebase -i and am merging this back into develop. I got a few conflicts, and I just want to use whatever code is on my feature branch. I tried "mine" but that actually seemed to do the opposite.

Could someone shed some light on this terminology?


回答1:


ours and theirs is a somewhat confusing concept; exacerbated when performing a rebase:

When performing a merge, ours refers to the branch you're merging into, and theirs refers to the branch you are merging from. So if you are trying to resolve conflicts in the middle of a merge:

  • use ours to accept changes from the branch we are currently on
  • use theirs to accept changes from the branch we are merging into.

That makes sense, right?

When rebasing, ours and theirs are inverted. Rebases pick files into a "detached" HEAD branch. The target is that HEAD branch, and merge-from is the original branch before rebase. That makes:

  • --ours the anonymous one the rebase is constructing, and
  • --theirs the one being rebased;

I.e., rebasing replays the current branch's commits (one at a time) on top of the branch that we intend to rebase with.




回答2:


"Ours" (and "mine") refer to the current branch; "theirs" refers to the branch being merged in. It sounds like you actually wanted to use "theirs".



来源:https://stackoverflow.com/questions/31817210/git-confusion-over-terminology-theirs-vs-mine

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