Is it possible to do following?
- Make
git rebase --interactive
to just output standard boilerplate to a file, instead to outputting to a file and opening it in editor. - Let the user edit the file.
- Let user re-run
git rebase
with the name of edited file. - Go on with the usual rebase process.
Usecase: scripted rebasing of course. See how to re-order commits in Git non-interactively for example.
You can use
touch
as the editor which will touch the file so it will appear modified. For exampleTo alias it, given
baseline
as a tag I want to rebase againstThe alias works under Windows because the shell it is executing is
bash
notcmd
.Expanding on pfalcon's answer:
If you have an environment variable that contains the contents you want:
Catting a file would work too:
Adding on to @pfalcon's answer, you can use sed as your GIT_SEQUENCE_EDITOR. For example, I wanted to edit each commit, so I did this:
interactive modes brings up the set editor to work with.
the editor in use can be retrieved with:
So, if you set a non-interactive editor - that is an editor that accepts commands on stdin, you can work with
--interactive
in a non-interactive way :)I know for sure
vim
accepts commands, and so does the standard editored
, ofcourse.so, hold the interactive editor (if wanted)
set the non-interactive editor
and do work with it..
and restore the editor (if wanted)
Based on Jezz's answer, I made a shell-agnostic script (GitReb) which works with multiple-argument revisions,
:/<text>
syntax, root commit and also does some sanity checks.I also made it simpler and removed the
t
/split
action anddelete
->drop
conversion which IMO are out of this script's scope.I use this script (in add it allows to simplify commit splitting):
Add an alias to your .gitconfig: