{"id":7780,"date":"2026-04-25T09:31:35","date_gmt":"2026-04-25T07:31:35","guid":{"rendered":"https:\/\/yoota.it\/en\/git-2-54-brings-targeted-history-rewrites-config-based-hooks-and-geometric-maintenance-by-default\/"},"modified":"2026-04-25T09:31:36","modified_gmt":"2026-04-25T07:31:36","slug":"git-2-54-brings-targeted-history-rewrites-config-based-hooks-and-geometric-maintenance-by-default","status":"publish","type":"post","link":"https:\/\/yoota.it\/en\/git-2-54-brings-targeted-history-rewrites-config-based-hooks-and-geometric-maintenance-by-default\/","title":{"rendered":"Git 2.54 brings targeted history rewrites, config-based hooks, and geometric maintenance by default"},"content":{"rendered":"\n<p>Fixing an old commit message in Git, using traditional tools, often requires more steps than necessary: interactive rebase, editing the todo list, selecting the right commit, closing the rebase. It works, but it&#8217;s a mechanism designed for broader rewrites. In the post about Git 2.54, GitHub highlights a new experimental command, <code>git history<\/code>, built specifically for targeted rewrites; the same article also covers features introduced in 2.53.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">git history: less friction for targeted rewrites<\/h2>\n\n\n\n<p>The new experimental command <code>git history<\/code> is designed for rewriting history in specific cases and currently exposes two operations: <code>reword<\/code> and <code>split<\/code>. The official documentation explicitly presents it as an experimental history rewriting command, not as a general replacement for <code>git rebase<\/code>.<\/p>\n\n\n\n<p><code>git history reword &lt;commit&gt;<\/code> opens your editor with the message of the specified commit and rewrites it while leaving everything else unchanged. By default it updates local branches pointing to commits descended from the rewritten one; alternatively it can update only <code>HEAD<\/code>. Unlike <code>git rebase<\/code>, it doesn&#8217;t touch the index or working tree, and can operate on bare repositories.<\/p>\n\n\n\n<p><code>git history split &lt;commit&gt;<\/code> lets you break a commit into two by interactively choosing which hunks to move into a new parent commit. The interface mirrors <code>git add -p<\/code>, and the documentation also allows limiting the operation to a <code>pathspec<\/code>.<\/p>\n\n\n\n<p>The limitations are intentional. <code>git history<\/code> doesn&#8217;t yet work on histories containing merges and refuses operations that would create conflicts. It&#8217;s a tool for predictable, focused interventions, not for complex or open-ended rewrites.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Hooks defined in configuration files<\/h2>\n\n\n\n<p>One of Git 2.54&#8217;s most interesting additions is the ability to define hooks directly in configuration files, rather than relying solely on scripts in the traditional hooks directory. This lets you place hooks in your <code>~\/.gitconfig<\/code> file, in system configuration, or in the repository&#8217;s local config, making it far simpler to share the same hooks across multiple projects.<\/p>\n\n\n\n<p>A minimal example looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">[hook \"linter\"]\n    event = pre-commit\n    command = ~\/bin\/linter<\/pre>\n\n\n\n<p>The <code>hook.&lt;name&gt;.event<\/code> key defines the event that triggers the hook, while <code>hook.&lt;name&gt;.command<\/code> specifies the command to run. You can define multiple hooks for the same event; Git executes them in the order it encounters them in configuration. The traditional script in the hooks directory still works and runs last.<\/p>\n\n\n\n<p>To see which hooks are active, use <code>git hook list pre-commit<\/code>, specifying the event type. The manual page documents <code>list<\/code> as a subcommand that prints hooks for a specific event.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">More efficient maintenance by default<\/h2>\n\n\n\n<p>On the maintenance front, Git 2.54 makes <code>geometric<\/code> the default strategy for manual maintenance. When you run <code>git maintenance run<\/code> without specifying a strategy, Git now uses the geometric approach instead of the older <code>gc<\/code> task.<\/p>\n\n\n\n<p>The <code>geometric<\/code> strategy was introduced in Git 2.52 as an explicit option; it&#8217;s now the default for manual maintenance. The documentation describes it as a complete replacement for the <code>gc<\/code> strategy and particularly recommends it for large repositories.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Other improvements<\/h2>\n\n\n\n<p><code>git add -p<\/code> now shows, as you move between hunks with <code>J<\/code> and <code>K<\/code>, which sections have already been accepted or skipped in the current session. The same round of improvements includes <code>--no-auto-advance<\/code>, which prevents automatic progression to the next file when you reach the last hunk.<\/p>\n\n\n\n<p><code>git rebase<\/code> also gains a new <code>--trailer<\/code> parameter, which adds a trailer to all commits rewritten during the rebase using <code>interpret-trailers<\/code>; a typical example is a line like <code>Reviewed-by<\/code>.<\/p>\n\n\n\n<p>Finally, aliases are no longer limited to the old ASCII alphanumeric set plus hyphens. With the new subsection syntax, any characters are allowed except newlines and NUL bytes, so you can use non-Latin names or accented characters.<\/p>\n\n\n\n    \n    <div class=\"yoota-fonte\">\n        <a href=\"https:\/\/github.blog\/open-source\/git\/highlights-from-git-2-54\/\" target=\"_blank\" rel=\"nofollow noopener\" class=\"yoota-fonte-hit\">\n            \n            <span class=\"yoota-fonte-icon\" aria-hidden=\"true\">\n                <i class=\"ri-external-link-line\"><\/i>\n            <\/span>\n\n            <span class=\"yoota-fonte-content\">\n                <span class=\"yoota-fonte-label\">SOURCE:\/\/<\/span>\n\n                                    <span class=\"yoota-fonte-link\">\n                        github.blog                    <\/span>\n                            <\/span>\n\n        <\/a>\n    <\/div>\n    \n    \n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Git 2.54 introduces git history for targeted rewrites, configuration-based hooks, and geometric maintenance as the new default for performance improvements.<\/p>\n","protected":false},"author":2,"featured_media":7779,"comment_status":"open","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"italian_url":"https:\/\/yoota.it\/git-2-54-introduce-git-history-hook-da-configurazione-e-maintenance-geometrica-di-default\/","yoota_meta_description":"","activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":""},"categories":[51],"tags":[87,107,353],"class_list":["post-7780","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","tag-git","tag-open-source","tag-software-development"],"_links":{"self":[{"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/posts\/7780","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/comments?post=7780"}],"version-history":[{"count":1,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/posts\/7780\/revisions"}],"predecessor-version":[{"id":7782,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/posts\/7780\/revisions\/7782"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/media\/7779"}],"wp:attachment":[{"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/media?parent=7780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/categories?post=7780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yoota.it\/en\/wp-json\/wp\/v2\/tags?post=7780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}