Achraf JEDAY
Achraf JEDAY

Reputation: 2114

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:

Merge pull request #77 ...

I prefer to get a git history without these merge commits.

How can I achieve that?

Upvotes: 34

Views: 25382

Answers (2)

Mark Adelsberger
Mark Adelsberger

Reputation: 45819

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.

A rebase will result in one or more new commits (any or all of which may be in a "broken"/unbuildable state) at the head of the main branch.

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

Upvotes: 12

Achraf JEDAY
Achraf JEDAY

Reputation: 2114

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:

enter image description here

Upvotes: 29

Related Questions