git/Documentation/config
Harald Nordgren e439185efd history: add squash subcommand to fold a range
Folding a series of commits into one required either an interactive
rebase where each commit after the first was hand-edited to "fixup", or
a "git reset --soft" to the merge base followed by "git commit --amend".

Add "git history squash <revision-range>" to do this directly. It folds
every commit in the range into the oldest one, keeping that commit's
authorship and taking the tree of the newest commit, then replays the
commits above the range on top. The squashed message comes from the
oldest commit by default, or from the body of the last amend! commit
targeting it. An editor opens with the selected message when
--reedit-message is given. A fixup!, squash! or amend! commit is refused
unless the commit it targets is also in the range, so the fold does not
silently absorb a marker meant for a commit outside it. The check runs
the range through todo_list_rearrange_squash(), which leaves such a
marker as a plain pick. Markers whose target is in the range fold in as
usual. As an exception, a range made up entirely of markers for one
target is combined anyway, taking its message from the last amend! if
there is one, so a batch of fixups for the same commit can be collapsed.

The range is read like the arguments to "git rev-list", so several
revisions such as "HEAD~3..HEAD ^topic" may be given, and rev-list
options are accepted too. As "git replay" does, the walk options the fold
relies on are forced after setup_revisions() and a warning is printed if
an option changed them, so the first commit returned is the range's
oldest and its parent is the base regardless of what the user passed
(including after a "--"). A merge inside the range is folded when its
other parent is reachable from the base, otherwise the range has more
than one base and is rejected. By default the command also refuses when a
ref points at a commit that the fold would discard. Use --update-refs=head
to rewrite only the current branch instead.

Inspired-by: Sergey Chernov <serega.morph@gmail.com>
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-07-20 07:35:18 -07:00
..
add.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
advice.adoc history: add squash subcommand to fold a range 2026-07-20 07:35:18 -07:00
alias.adoc doc: fix list continuation in alias.adoc 2026-03-03 09:59:31 -08:00
am.adoc doc: convert git-am synopsis and options to new style 2026-05-25 20:05:44 +09:00
apply.adoc doc: convert git-apply synopsis and options to new style 2026-05-25 20:05:44 +09:00
attr.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bitmap-pseudo-merge.adoc pack-bitmap: reject pseudo-merge "sampleRate" of 0 2026-05-12 10:36:18 +09:00
blame.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
branch.adoc doc: improve formatting in branch section 2025-06-30 11:11:36 -07:00
browser.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
bundle.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
checkout.adoc doc: convert git-checkout manpage to new style 2025-05-27 07:50:58 -07:00
clean.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
clone.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
color.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
column.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
commit.adoc doc: config: mention core.commentChar on commit.cleanup 2025-05-27 15:31:06 -07:00
commitgraph.adoc commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
completion.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
core.adoc Merge branch 'pc/lockfile-pid' 2026-02-17 13:30:41 -08:00
credential.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
diff.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
difftool.adoc doc: convert git-difftool manual page to synopsis style 2026-04-06 09:38:18 -07:00
extensions.adoc Merge branch 'kn/ref-location' 2026-03-04 10:52:59 -08:00
fastimport.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
feature.adoc setup: use "reftable" format when experimental features are enabled 2025-07-07 06:26:21 -07:00
fetch.adoc fetch: add configuration variable fetch.followRemoteHEAD 2026-06-19 09:19:36 -07:00
filter.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fmt-merge-msg.adoc doc: switch merge config description to new synopsis format 2025-05-27 07:51:00 -07:00
format.adoc Fix docs for format.commitListFormat 2026-04-22 16:16:24 -07:00
fsck.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
fsmonitor--daemon.adoc fsmonitor: implement filesystem change listener for Linux 2026-04-15 08:44:33 -07:00
gc.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gitcvs.adoc completion: make sed command that generates config-list.h portable. 2025-06-02 17:21:49 -07:00
gitweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
gpg.adoc gpg-interface: expand gpg.program as a path 2025-07-14 10:07:02 -07:00
grep.adoc doc: convert git-grep synopsis and options to new style 2026-05-25 20:05:44 +09:00
gui.adoc config: document 'gui.GCWarning' 2025-12-09 07:38:56 +09:00
guitool.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
help.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
hook.adoc doc: hook: don’t self-link via config include 2026-05-22 09:36:20 +09:00
http.adoc doc: clarify http.emptyAuth values 2026-05-01 14:01:57 +09:00
i18n.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
imap.adoc doc: convert git-imap-send synopsis and options to new style 2026-05-25 20:05:45 +09:00
includeif.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
index.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
init.adoc submodule: allow runtime enabling extensions.submodulePathConfig 2026-01-12 11:56:56 -08:00
instaweb.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
interactive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
log.adoc log: improve --follow following renames for non-linear history 2026-06-22 05:45:09 -07:00
lsrefs.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailinfo.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
mailmap.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
maintenance.adoc builtin/maintenance: use "geometric" strategy by default 2026-02-24 07:33:20 -08:00
man.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
merge.adoc merge/pull: extend merge.stat configuration variable to cover --compact-summary 2025-06-13 11:54:14 -07:00
mergetool.adoc doc: convert git-difftool manual page to synopsis style 2026-04-06 09:38:18 -07:00
notes.adoc Merge branch 'bc/doc-adoc-not-txt' 2025-02-14 17:53:47 -08:00
pack.adoc doc: fix plural agreement in pack.preferBitmapTips 2026-04-16 21:22:01 -07:00
pager.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pretty.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
promisor.adoc Merge branch 'cc/promisor-auto-config-url-more' 2026-07-06 15:50:19 -07:00
protocol.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
pull.adoc pull: add pull.autoStash config option 2025-07-21 15:01:21 -07:00
push.adoc doc: clarify push.default=simple behavior 2026-05-26 20:11:29 +09:00
rebase.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
receive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
reftable.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
remote.adoc Merge branch 'mh/fetch-follow-remote-head-config' 2026-07-06 15:50:22 -07:00
remotes.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
repack.adoc repack: introduce `--write-midx=incremental` 2026-05-20 11:31:14 +09:00
replay.adoc replay: add replay.refAction config option 2025-11-05 13:34:55 -08:00
rerere.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
revert.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
safe.adoc Merge branch 'ta/doc-config-adoc-fixes' 2026-06-17 11:10:11 -07:00
sendemail.adoc doc: fix self-referential config in sendemail.smtpSSLClientKey 2026-04-16 21:22:01 -07:00
sequencer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
showbranch.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
sideband.adoc Merge branch 'ta/doc-config-adoc-fixes' 2026-06-17 11:10:11 -07:00
sparse.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
splitindex.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
ssh.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
stash.adoc Merge branch 'dk/stash-apply-index' 2025-10-20 14:12:17 -07:00
status.adoc status: clarify how status.compareBranches deduplicates 2026-03-04 10:13:33 -08:00
submodule.adoc doc: fix grammar errors in submodule description 2026-04-16 21:22:01 -07:00
tag.adoc doc: convert git tag to synopsis style 2025-10-05 16:09:03 -07:00
tar.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trace2.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
trailer.adoc doc: config: convert trailers section to synopsis style 2026-03-16 15:04:37 -07:00
transfer.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadarchive.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
uploadpack.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
url.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
user.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
versionsort.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
web.adoc doc: use .adoc extension for AsciiDoc files 2025-01-21 12:56:06 -08:00
worktree.adoc doc: convert git worktree to synopsis style 2025-10-05 16:09:03 -07:00