Version Control: Using squash merge when merging PRs to master
See original GitHub issueIn my opinion, when we merge PRs, we should be squashing the commits before merging it. A PR is usually related to one logical change as:
- during the course of development, developers usually keep creating commits after small changes
- whenever a PR is reviewed, new commits are made to address issues pointed in reviewer’s comments
Doing a squash would have the following advantages:
- will keep out git history clean. Viewing the
git log
will clearly show how features were added/things were fixed. - will make it easier to check the change done by building a particular feature. Rather than viewing multiple commits
git show <commit_id>
will show the changes - will make it easier to revert a change
- cherry picking a change to another branch(say release branch) would be much easier. 😃
It would be great if we could reach a consensus on this and start following the practise.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:2
- Comments:8 (5 by maintainers)
Top Results From Across the Web
Merge strategies and squash merge - Azure Repos
Squash merging is a merge option that allows you to condense the Git history of topic branches when you complete a pull request....
Read more >Configuring commit squashing for pull requests - GitHub Docs
Under "Pull Requests", select Allow squash merging. This allows contributors to merge a pull request by squashing all commits into a single commit....
Read more >Using git merge --squash to merge develop into master when ...
A merge from master to develop is needed by most repos that have a lot of activity when "hotfixes" come into play. Your...
Read more >How to Squash Commits in Git | Learn Version Control with Git
When integrating commits from one branch into another, the 'squash' option allows you to combine multiple commits into one.
Read more >Squash and merge - GitLab Docs
On the top bar, select Main menu > Projects and find your project. · On the left sidebar, select Settings > Merge requests....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree with this, especially after having had to cherry pick through multiple-commit PRs recently. 😉
I think the simplest way to do this is for reviewers to use the web interface and click on the drop-down button then select “squash merge”. Given that it’s so simple, if we do decide to go with this, I’d personally prefer to request reviewers to all start right away for consistency (so that we don’t have some squashed commits along with a whole trail of unsquashed ones).
@nicolas-raoul No, senders don’t need to do anything special. 😃
Good idea! It does not require the sender of a pull request to do anything special, right?
How about this: