简体   繁体   English

如何在Git历史记录中合并拉取请求而不获取合并提交

[英]How to merge a pull request without getting a merge commit in the Git history

On Github every time I merge a pull request into my base branch I get an extra merge commit: 每次我将拉取请求合并到我的基本分支时,在Github上我得到一个额外的合并提交:

Merge pull request #77 ... 合并拉动请求#77 ...

I prefer to get a git history without these merge commits. 我更喜欢在没有这些合并提交的情况下获得git历史记录。

How can I achieve that? 我怎样才能做到这一点?

To get a git history without any pull request merge commits I can use the merge button (Pull request page) and perform a rebase and merge: 要获得没有任何拉取请求合并提交的git历史记录,我可以使用合并按钮(拉取请求页面)并执行rebase并合并:

在此输入图像描述

I will never understand (or, I should say, agree with) all the people who insist that merges in the history are "less clean". 我永远不会理解(或者,我应该说,同意)所有那些坚持认为历史上的合并“不那么干净”的人。 But ok, here are your options: 但好的,这是您的选择:

  • Squash 壁球
  • Rebase 变基
  • Merge 合并

A squash will result in a single new commit representing all changes at the head of the main branch. 压缩将导致一个新的提交,表示主分支头部的所有更改。 It is a special case of rebase. 这是rebase的一个特例。

A rebase will result in one or more new commits (any or all of which may be in a "broken"/unbuildable state - but hey, this is your definition of clean, not mine) at the head of the main branch. 一个rebase将导致一个或多个新提交(任何或所有提交可能处于“破坏”/不可建状态 - 但是,嘿,这是对主干分支的清洁而不是我的定义)。

A merge creates a merge commit and leaves history as it really happened. 合并创建合并提交并保留历史记录。

Here is documentation of the options: https://github.com/blog/2243-rebase-and-merge-pull-requests 以下是选项的文档: https//github.com/blog/2243-rebase-and-merge-pull-requests

(Yes, I'm aware of the standard gripe that external links aren't reliable. If github's site goes away, then the question becomes moot anyway; so I'm not retyping their documentation.) (是的,我知道外部链接不可靠的标准抱怨。如果github的网站消失了,那么这个问题无论如何都会变得没有意义;所以我不会重新输入他们的文档。)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM