Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to presupply git rebase with the list to use for rebase

Tags:

git

git-rebase

Instead of git rebase -i and editing manually is there a possibility to supply git rebase with the pick/drop/squash list as a text file, or do I need to redirect GIT_EDITOR to a script that supplies it ?

like image 495
Konrad Eisele Avatar asked Nov 28 '25 03:11

Konrad Eisele


1 Answers

You'll need to use GIT_EDITOR or GIT_SEQUENCE_EDITOR to edit the file in place. That program will receive the file name as its argument, and can be a shell command, so you can do something like this:

GIT_SEQUENCE_EDITOR='sed -i -e '\''2,$s/^pick/fixup/'\' git rebase

The difference between the two editors is that GIT_SEQUENCE_EDITOR only applies to the rebase todo list, but not to other things like commit messages, whereas GIT_EDITOR applies to both. So, for example, if you want to automatically squash in all squash and fixup commits created by git commit --squash and git commit --fixup without prompting, you can do this:

GIT_SEQUENCE_EDITOR=true git rebase -i --autosquash main

That automatically accepts the squash and fixup commands without prompting, but still leaves your normal editor for editing commit messages due to squash commits.

like image 167
bk2204 Avatar answered Nov 30 '25 23:11

bk2204