13

At my company we ask developers to squash commits on feature branches before merging into develop. Once squashed, the developer pushes to GitHub and logs into GitHub to create a pull request.

When the pull request is merged, we end up seeing two commits in the history of the develop branch:

  1. A commit saying "merged pull request"
  2. The single, squashed commit from the feature branch

Why does this happen? And how can we avoid it? I've read a similar Q&A about avoiding "merge commit hell" but my goal is to use the GitHub UI to create, track, and discuss pull requests.

1
  • I think the second commit is a merge commit. To avoid it, you have merge it manually and then push it to GitHub. GitHub does not have the feature to dismiss the merge commit. Check here. Commented Apr 7, 2016 at 22:22

1 Answer 1

13

The commit you're seeing is a merge commit; generally these are auto-created by git any time you do a non-fast-forward merge, but you can also force one to always be created. And that is what GitHub does when you use the merge button.

If you don't want merge commits, then you need to cherry-pick commits onto master instead of using the merge button. There is no way to do this within the GitHub web UI.

Edit: GitHub has now added squash and merge and rebase and merge capabilities within their web UI:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

So seems like there's now way to avoid the merge commit in GitHub... That really sucks. I generally love the GitHub pull request UI, but these merge requests are annoying and definitely confused me, because the diff shows exactly the same diff as what the squashed commit preceding it shows.
Merge commits make a lot more sense when you look at a tree view of history, which unfortunately GitHub doesn't provide. I love GitHub, but as the years go on I spend more and more time using git tools in the terminal instead of the "pretty" views they provide, since it inevitably ends up being more confusing when you're trying to do something beyond the slightly basic operations.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.