Git: How to make a single commit of multiple commits when merging pull request?

Viewed 1477

At work, we always generate 2 commits when merging a PR. The first one would be a commit for a feature and a separate commit for the merge.

Personally, I find having merge commits would clutter the git log. So I wonder what's the convention or best practices for this?

1 Answers

You can squash while merging pull request, it will create a single commit. Switch to branch in which you have to merge (let's assume it's master), merge it using squash, commit and push, as follows:

git checkout master
git merge pull-request-branch --squash
git commit -m "Pull request merged in master"
git push origin master
Related