DEV Community

AK DevCraft
AK DevCraft Subscriber

Posted on • Edited on

A simple tip to keep GitHub commit history less cluttered

No matter what Git branching strategy you are using, you’ll still open a pull request (PR) for peer review. No one is perfect and anyone hardly remembers their code after few weeks😬

Once PR is reviewed and approved, you would merge it to the destination branch. But, at this point when we're merging the PR, we can decide whether to use "Merge pull request" or "Squash and merge". Any of these options will ultimately merge the code into the destination branch, however, we can control how commit history is propagated to the destination branch.

options to merge

The recommendation is to choose the "Squash and merge" option, as it just creates one single commit in the destination branch, hiding all the commits coming from the source branch i.e. as the name says, it squashes all commits into one commit.

clean commit history

And yet we have the option to see commits that came from the source by traversing through the newly created commit. In other words, by clicking on the PR number that was merged e.g. #1 in the above screenshot. This helps to keep the destination/main branch's commit history neat and tidy.

access to commit history

Whereas, if we choose the "Merge pull request" option, all commits along with a new commit for the PR will be created in the destination branch. And that looks like finding commit in a haystack.

clutter commit history

But in the end, it's up to you how you want to maintain your branch's commit history😃. Whatever you choose, May the force be with you!

If you have reached here, then I did a satisfactory effort to keep you reading. Please be kind to leave any comments or ask for any corrections. Happy Coding!

Image of Timescale

Timescale – the developer's data platform for modern apps, built on PostgreSQL

Timescale Cloud is PostgreSQL optimized for speed, scale, and performance. Over 3 million IoT, AI, crypto, and dev tool apps are powered by Timescale. Try it free today! No credit card required.

Try free

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay