<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt" -->

---
title: Introducing `dolt_squash_history()` | daily.dev
description: Dolt, the version-controlled database, introduces `dolt_squash_history()`, a new SQL procedure that collapses an entire branch's commit history into a single...
canonical: https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Introducing `dolt_squash_history()` | daily.dev
og:description: Dolt, the version-controlled database, introduces `dolt_squash_history()`, a new SQL procedure that collapses an entire branch's commit history into a single...
og:url: https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt
og:image: https://api.daily.dev/og/posts/gbwjiEmTt.png
og:image:alt: Introducing `dolt_squash_history()`
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Introducing `dolt_squash_history()`

**[DoltHub Blog](https://daily.dev/sources/dolthub-blog)** · 8 min read · 16 upvotes · 0 comments

## Summary

Dolt, the version-controlled database, introduces `dolt_squash_history()`, a new SQL procedure that collapses an entire branch's commit history into a single commit in constant time. Unlike `dolt_rebase()` which replays every commit, `dolt_squash_history()` uses a pointer trick internally — writing one new commit with HEAD's data and reparenting it onto the initial commit — making it dramatically faster. A demo shows squashing 100 commits dropping from 1.6s (rebase) to 0.15s, and after running `dolt gc --full`, disk usage shrank from 8.5MB to 172KB (50x reduction). The procedure supports partial squashing via `--first`, requires a clean working set and a commit message, and rewrites history so remotes should be used as archives before squashing.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://dolthub.com/blog/2026-07-31-squash-history>

## Questions this post answers

### How do I collapse all commit history into a single commit in Dolt without using dolt_rebase?

Use the dolt_squash_history() stored procedure, called as CALL dolt_squash_history('-m', 'message'). It collapses the current branch's entire history into one commit holding the data at HEAD, reparented onto the initial commit, without replaying any commits, so it runs in roughly constant time regardless of history depth. The working set must be clean and a message is required.

_Teams cutting Dolt history bloat can track procedures like this via daily.dev before their next cleanup._

### How much faster is dolt_squash_history compared to dolt_rebase for squashing commits in Dolt?

On a 100-commit demo database, dolt_squash_history() took 0.15 seconds versus 1.60 seconds for the equivalent dolt_rebase() squash, roughly ten times faster, because it writes one commit and moves a pointer instead of replaying every commit. On a million-commit database the squash still takes only milliseconds, while rebase cost grows with history length.

_Anyone comparing Dolt history management tools can follow performance details like these on daily.dev._

### Can I squash only part of my commit history in Dolt while keeping older commits intact?

Yes, dolt_squash_history() accepts a --first flag marking the oldest commit to include in the squash; everything from that commit through HEAD collapses into one commit while history older than --first is preserved. The --first argument accepts a commit hash, a HEAD~N expression, or a branch name.

_Developers planning selective history cleanup in Dolt can keep tabs on procedures like this via daily.dev._

## Similar posts on daily.dev

- [The git history command deserves more attention](https://daily.dev/posts/the-git-history-command-deserves-more-attention-4x11kdegr) · Hacker News · 9 upvotes · 0 comments
- [What People Are Saying: Better Stack Edition](https://daily.dev/posts/what-people-are-saying-better-stack-edition-e20vhxeem) · DoltHub Blog · 0 upvotes · 0 comments
- [Version Controlled SQL Database Dolt Releases 2.0 with Automatic Storage Cleanup and Compression](https://daily.dev/posts/version-controlled-sql-database-dolt-releases-2-0-with-automatic-storage-cleanup-and-compression-wfaha9aol) · InfoQ · 1 upvotes · 0 comments
- [Git Commands For a Single Commit](https://daily.dev/posts/git-commands-for-a-single-commit-rbwx1zjhh) · Atomic Spin · 1 upvotes · 1 comments

---

Tags: [#backend](https://daily.dev/tags/backend), [#git](https://daily.dev/tags/git), [#version-control](https://daily.dev/tags/version-control)

[View this post on daily.dev](https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Introducing `dolt_squash_history()`","url":"https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt"},"datePublished":"2026-07-31T19:58:34.426Z","dateModified":"2026-09-13T19:05:47.919Z","description":"Dolt, the version-controlled database, introduces `dolt_squash_history()`, a new SQL procedure that collapses an entire branch's commit history into a single...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0919d0530add565721e4e3de2a7981c9?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/0919d0530add565721e4e3de2a7981c9?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"DoltHub Blog","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"DoltHub Blog","logo":"https://media.daily.dev/image/upload/s--LXDlvjS4--/f_auto,q_auto/v1780213587/logos/dolthub-blog?_a=BAMAMiWQ0","url":"https://daily.dev/sources/dolthub-blog"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":16},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"backend,git,version-control","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"DoltHub Blog","item":"https://daily.dev/sources/dolthub-blog"},{"@type":"ListItem","position":3,"name":"Introducing `dolt_squash_history()`"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/introducing-dolt-squash-history--gbwjiemtt#faq","mainEntity":[{"@type":"Question","name":"How do I collapse all commit history into a single commit in Dolt without using dolt_rebase?","acceptedAnswer":{"@type":"Answer","text":"Use the dolt_squash_history() stored procedure, called as CALL dolt_squash_history('-m', 'message'). It collapses the current branch's entire history into one commit holding the data at HEAD, reparented onto the initial commit, without replaying any commits, so it runs in roughly constant time regardless of history depth. The working set must be clean and a message is required. Teams cutting Dolt history bloat can track procedures like this via daily.dev before their next cleanup."}},{"@type":"Question","name":"How much faster is dolt_squash_history compared to dolt_rebase for squashing commits in Dolt?","acceptedAnswer":{"@type":"Answer","text":"On a 100-commit demo database, dolt_squash_history() took 0.15 seconds versus 1.60 seconds for the equivalent dolt_rebase() squash, roughly ten times faster, because it writes one commit and moves a pointer instead of replaying every commit. On a million-commit database the squash still takes only milliseconds, while rebase cost grows with history length. Anyone comparing Dolt history management tools can follow performance details like these on daily.dev."}},{"@type":"Question","name":"Can I squash only part of my commit history in Dolt while keeping older commits intact?","acceptedAnswer":{"@type":"Answer","text":"Yes, dolt_squash_history() accepts a --first flag marking the oldest commit to include in the squash; everything from that commit through HEAD collapses into one commit while history older than --first is preserved. The --first argument accepts a commit hash, a HEAD~N expression, or a branch name. Developers planning selective history cleanup in Dolt can keep tabs on procedures like this via daily.dev."}}]}
```

