Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Squash And Merge in GitHub?

Tags:

git

github

While merging Pull-Requests (PR) on GitHub, there is one option "Squash And Merge", What is purpose of that and what it will do ??

like image 612
Vishal Ribdiya Avatar asked Jan 01 '26 07:01

Vishal Ribdiya


2 Answers

This blog post from Github may help.

The basic idea is that all the commits you added on your feature branch, will be put together into one, large commit, making the git tree easier to read. This is particularly useful if you frequently reverted mistakes in your branch.

like image 65
Jayrassic Avatar answered Jan 03 '26 03:01

Jayrassic


Sometimes while working on a task you create a lot of minor commits, that you may not want to be on your master branch. So that you can squash them before a merge and leave only one, fully descriptive commit.

Also, there may be some conventions in the developer team to have a more concise, shorter git history in the repo. Like for example one commit per one feature (even though there was a couple on the feature branch). Then it's easier to go through recent commits and so on.

like image 34
Aleksandra Sikora Avatar answered Jan 03 '26 03:01

Aleksandra Sikora