* rebasing on top of reformatted branch
@ 2025-12-17 6:33 Simon Richter
2025-12-17 8:56 ` Kristoffer Haugsbakk
0 siblings, 1 reply; 2+ messages in thread
From: Simon Richter @ 2025-12-17 6:33 UTC (permalink / raw)
To: git
Hi,
I need to rebase a branch on top of a version that has had automatic
formatting applied.
My usual approach for this is to create an empty extra commit after the
branch point, then filter-branch all the commits on my branch with the
same automatic formatting, then continue rebasing. Because the filter is
applied to the tree, no three-way merges are performed, avoiding the
conflicts.
Is there a way to automate this in a nicer way, especially if I have
multiple branches that need to be rebased in this way?
Simon
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: rebasing on top of reformatted branch
2025-12-17 6:33 rebasing on top of reformatted branch Simon Richter
@ 2025-12-17 8:56 ` Kristoffer Haugsbakk
0 siblings, 0 replies; 2+ messages in thread
From: Kristoffer Haugsbakk @ 2025-12-17 8:56 UTC (permalink / raw)
To: Simon Richter, git
On Wed, Dec 17, 2025, at 07:33, Simon Richter wrote:
> I need to rebase a branch on top of a version that has had automatic
> formatting applied.
>
> My usual approach for this is to create an empty extra commit after the
> branch point, then filter-branch all the commits on my branch with the
> same automatic formatting, then continue rebasing. Because the filter is
> applied to the tree, no three-way merges are performed, avoiding the
> conflicts.
>
> Is there a way to automate this in a nicer way, especially if I have
> multiple branches that need to be rebased in this way?
I haven’t tried it but git-test from git-branchless should be able to
solve this.[1][2]
> > git-branchless’s git test command offers a solution to quickly run
> > formatters, etc., on an entire stack of commits without causing merge
> > conflicts.
> > [...]
> > git test run --exec 'cargo fmt --all' --strategy worktree --jobs 8
That sounded great to me when I first read it (to transform the trees
per snapshot). *Obvious in hindsight* considering the trend of
autoformatters in various languages.
🔗 1: https://blog.waleedkhan.name/formatting-a-commit-stack/
† 2: Not to be confused with some git-test(1) scripts that run tests per
commit in a revision range and store failure/success
I uninstalled git-branchless because it created so many weird refs and
hooks and I didn’t understand the overarching goal of the command
suite. I still have hooks like this laying around. :)
#!/bin/sh
## START BRANCHLESS CONFIG
# This hook has been uninstalled.
# Run `git branchless init` to reinstall.
## END BRANCHLESS CONFIG
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-12-17 8:57 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 6:33 rebasing on top of reformatted branch Simon Richter
2025-12-17 8:56 ` Kristoffer Haugsbakk
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox