Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

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?

like image 471
Achraf JEDAY Avatar asked May 12 '17 12:05

Achraf JEDAY


2 Answers

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

like image 23
Mark Adelsberger Avatar answered Oct 08 '22 11:10

Mark Adelsberger


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

like image 54
Achraf JEDAY Avatar answered Oct 08 '22 13:10

Achraf JEDAY