2

I want to split an unpushed commit in the near history of the current branch. As long as I know this only is possible using interactive rebase (or by doing it completely manually).

How to invoke the interactive rebase so it will not show an text editor, e.g. by preparing the result of the editing?

4
  • What would you like, or expect, to happen if you don't specify in the editor what you'll be rebasing? Commented Sep 28, 2015 at 9:40
  • I would expect an error. Just want to avoid Git launching the editor. Commented Sep 28, 2015 at 10:16
  • How about a terminal editor like nano or vim? Commented Sep 28, 2015 at 10:18
  • No, the command should be invoked by an application without user interaction. Commented Sep 28, 2015 at 11:43

1 Answer 1

1

Do I understand correctly that you want to do the following:

  1. Prepare in advance (somewhere) your rebase interactive file
  2. Do the rebase without ever opening a text editor (say, on a different machine)

You can do this as follows:

First create a fake text editor: add the following contents to an sh file called edit.sh

cat file > $1 

where file refers to some location where you will put the instructions for the interactive rebase.

Make sure edit.sh is executable

Next, run the rebase as follows:

GIT_EDITOR=edit.sh git rebase -i branch_to_rebase_on 

Instead of opening an editor; this will open the sh script. The sh script simply writes the instructions for the rebase to the rebase file.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. Is there another, platform independent way of doing this, e.g. by launching git rebase -i with a certain option?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.