Github UI 合并的 3 种类型的细分

Breakdown of the 3 types of Github UI merges

我一直在使用 Github UI 合并 PR(拉取请求),UI 看起来像:

我正在尝试更仔细地了解这三件事是如何工作的。这是我对这三个选项的最佳猜测:

  1. 创建合并提交
git merge <base> <other>
  1. 压缩并合并
git merge --squash <base> <other>
  1. 变基并合并
git rebase <base> <other>

这准确吗?还是我遗漏了什么?

我在 中有这个答案的较长版本,但这里是 shorthand 的等价答案。所有人都假设你在基础分支上开始,即 git checkout <em>branch</em>。下面的 消息 Merge pull request #<em>number</em> from <em>repository</em> 并且 hash 是根据拉取请求自动计算的。

  1. 创建合并提交

    git merge --no-ff -m <em>消息哈希</em>

  2. 压缩并合并

    git merge --no-commit --squash <em>hash</em> && git commit -m <em>message </em>

  3. 变基并合并

    git rebase --force-rebase <em>hash</em>

(请注意,如果发生合并冲突,rebase-and-merge 将不起作用。我不清楚 GitHub 系统是否使用 --merge 来检查它,或者完全以其他方式。拉取请求已经检查了合并冲突与 git merge 有或没有 --squash; refs/pull/head/<em>number</em> 总是存在,但是 refs/pull/merge/<em>number</em> 只有在没有这样的冲突的情况下才存在,我想。他们——GitHub——还跟踪用于创建拉取请求 was/is 的 "base branch" 是否是最新的,但目前还不太清楚他们是如何做到这一点的。)