Pig
Pig

Reputation: 2122

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

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?

Upvotes: 4

Views: 2202

Answers (1)

Arpit Aggarwal
Arpit Aggarwal

Reputation: 29266

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

Upvotes: 4

Related Questions