Re: [PATCH v6 3/4] history: add squash subcommand to fold a range
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Jun 29, 2026, 05:50 UTC
- Message-ID
- <xmqqse65zyhw.fsf@gitster.g>
- In-Reply-To
- <811e393ab48e2f79e6f8c78d883a5b92311791b3.1782635349.git.gitgitgadget@gmail.com>
"Harald Nordgren via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 5 quoted lines
> @@ -11,6 +11,7 @@ SYNOPSIS > git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)] > git history reword <commit> [--dry-run] [--update-refs=(branches|head)] > git history split <commit> [--dry-run] [--update-refs=(branches|head)] [--] [<pathspec>...] > +git history squash <revision-range> [--dry-run] [--update-refs=(branches|head)] [--reedit-message]
Not your fault at all, as there are existing violators but the gitcli tells us that the canonical order of arguments on the command line is to have dashed options early before any real arguments.
Seeing <commit> followed by --dry-run, --update-refs, etc. with the existing subcommands should also be corrected and this new command should not spread the existing violation by mimicking. The revision range (which is not just a single token A..B, but the usual range notation that rev-list takes, like ^A B..C) should come after all these dashed options.
> +The range is given in the usual `<base>..<tip>` form, where _<base>_ is > +the commit just below the oldest commit to squash. For example, `git > +history squash @~3..` folds the three most recent commits into one, and
It is OK to use in your personal development, but in the official documentation, avoid cryptic @ and always spell HEAD (except for a single place that explain that @ can stand in for HEAD, for obvious reasons). It is extremely annoying and confusing to read as these look so similar to reflog notation for the current branch, e.g., @~1 vs @{1}.
So "squash HEAD~3..HEAD" specifies a range of commits HEAD~2, HEAD~1 and HEAD (three commits), these are squashed into one commit on top of HEAD~3, creating a sibling to HEAD~2 whose tree matches HEAD.
OK. Looking good.