Is there a command to say which branch is ours or theirs?

谁说我不能喝 提交于 2021-02-19 06:43:39

问题


There are plenty of SO answers and tutorials on the web that say there is a difference between which branch is ours and which branch is theirs depending on whether it's a rebase or a merge, and explain why, usually with a handy table, as do the man pages and online docs (sans the table).

Thing is, I don't care to remember. I'm not a fan of cognitive load for trivial things that the computer should be able to tell me or simply show me.

Is there a command or ENV var or suchlike that contains this information? (A search of my env brings up nothing but maybe I need to enable something first). The kind of thing I can stick in the prompt would be perfect. If it can handle the middle of rebase with a conflict where the target branch becomes a reference to the commit reached, that would be even better.

Judging by the amount of confusion and warnings about this you'll be doing everyone a favour by sharing if there is.

Any help or insight will be much appreciated.


回答1:


As I explained here:

whatever HEAD's pointing to is "ours"

The one tool that makes cristal clear what is ours vs theirs is VSCode.
See "Resolve merge conflicts"

  • The current change are ours.
  • The incoming change are theirs.




回答2:


When you merge A to B, where A and B are commit-ish(more than branches), B is ours and A is theirs. As commits, B = HEAD and A = MERGE_HEAD.

When you rebase A onto B, B is ours and A is theirs. As commits, B = HEAD and A = REBASE_HEAD.

When you cherry-pick A to B, B is ours and A is theirs. As commits, B = HEAD and A = CHERRY_PICK_HEAD.

You can use commands against HEAD, MERGE_HEAD, REBASE_HEAD and CHERRY_PICK_HEAD, like git show MERGE_HEAD.



来源:https://stackoverflow.com/questions/59657111/is-there-a-command-to-say-which-branch-is-ours-or-theirs

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