Thread (6 messages) 6 messages, 6 authors, 20d ago

Re: Programmatically edit the git rebase sequence?

From: Michal Suchánek <hidden>
Date: 2026-07-03 12:17:48

On Fri, Jul 03, 2026 at 02:02:33PM +0200, Matthias Beyer wrote:
Hi git people,

in a recent conversation at work, the question of how to
programmatically edit the git-rebase sequence came up.

Example use case:

I have a branch that touches a number of files, adds some files and
removes some files.
When rebasing, I want to split all commits that touched a certain subset
of files, for the clearity of the history.

I look at the output of

    git log master..mybranch --oneline --diff-filter=M -- "./subdir/*.rs"

to find all commits in that subdir that only touched the files. All of
these commits are to be "edit"ed.

Now I fire up `git rebase -i master` and manually(!) match the list from
above `git-log` call and find the respective commits to edit them.

Is there a way I am not aware of to do that manual step programatically?
Something like

    git rebase -i master --edit-commits="$(git log master..mybranch --diff-filter=M --format="%H" -- "./subdir/*.rs")"

would be convenient here, although I would understand if that is too
much clutter for the already very heavy git CLI interface :-)

Maybe I am just not aware of the obvious solution - I would be happy to
learn that there is already one!
Hello,

you could probably set a script as EDITOR (environment variable). Not
great for one-off scripts I guess.

Thanks

Michal
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help