Skip to content

Commit 756a114

Browse files
committed
Merge branch 'hn/history-squash' into seen
The experimental "git history" command has been taught a new "squash" subcommand to fold a range of commits into a single commit, replaying any descendants on top. * hn/history-squash: SQUASH??? avoid test_grep lint triggering on uses of raw grep SQUASH??? avoid test number clash by moving 3454-h-squash to 3455 history: re-edit a squash with every message history: add squash subcommand to fold a range history: give commit_tree_ext a message template history: extract helper for a commit's parent tree
2 parents 3a061f0 + 345117e commit 756a114

4 files changed

Lines changed: 521 additions & 38 deletions

File tree

Documentation/git-history.adoc

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(
1212
git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)]
1313
git history reword <commit> [--dry-run] [--update-refs=(branches|head)]
1414
git history split <commit> [--dry-run] [--update-refs=(branches|head)] [--] [<pathspec>...]
15+
git history squash <revision-range> [--dry-run] [--update-refs=(branches|head)] [--reedit-message]
1516

1617
DESCRIPTION
1718
-----------
@@ -113,6 +114,26 @@ linkgit:gitglossary[7].
113114
It is invalid to select either all or no hunks, as that would lead to
114115
one of the commits becoming empty.
115116

117+
`squash <revision-range>`::
118+
Fold all commits in _<revision-range>_ into the oldest commit of that
119+
range. The resulting commit keeps the oldest commit's message and
120+
authorship and takes the tree of the range's newest commit, so the
121+
whole range collapses into a single commit. Commits above the range
122+
are replayed on top of the result.
123+
+
124+
The range is given in the usual `<base>..<tip>` form, where _<base>_ is
125+
the commit just below the oldest commit to squash. For example, `git
126+
history squash @~3..` folds the three most recent commits into one, and
127+
`git history squash @~5..@~2` squashes an interior range while leaving
128+
the two newest commits in place.
129+
+
130+
The oldest commit's message and authorship are preserved by default. With
131+
`--reedit-message`, an editor opens pre-filled with the messages of all the
132+
folded commits so you can combine them. A merge commit inside the range is
133+
folded like any other, but the range must have a single base, so a range
134+
that reaches more than one entry point (for example a side branch that
135+
forked before the range and was later merged into it) is rejected.
136+
116137
OPTIONS
117138
-------
118139

0 commit comments

Comments
 (0)