Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git problem with interactive rebase

Tags:

git

msysgit

This is basically what happens:

> git rebase -i HEAD~3
Successfully rebased and updated refs/heads/master.

Pops open my text editor then immediately "completes" the rebase before I even have the chance to do anything. Anyone know what might be causing this?

I'm using msysgit on Windows 7: git version 1.7.3.1.msysgit.0

like image 604
Karl Avatar asked Dec 22 '10 20:12

Karl


People also ask

What is the problem with git rebase?

git rebase rewrites the commit history. It can be harmful to do it in shared branches. It can cause complex and hard to resolve merge conflicts. In these cases, instead of rebasing your branch against the default branch, consider pulling it instead ( git pull origin master ).

How do I use git interactive rebase?

You can run rebase interactively by adding the -i option to git rebase . You must indicate how far back you want to rewrite commits by telling the command which commit to rebase onto. Remember again that this is a rebasing command — every commit in the range HEAD~3..

How do I get out of interactive rebase?

you can abort the rebase by deleting the entire contents of the editor window and saving it, or causing the editor to close with an error code. In vim this can be accomplished with d SHIFT+g followed by :wq , or alternatively causing the editor to exit with an error as Mike H-R pointed out out using :cq .


2 Answers

This is probably because Git expects that the text editor will stop and wait until you have finished editing before continuing. Your text editor could start up in such a way that it appears that it immediately finished as far as Git can see.

You could try setting the EDITOR environment variable to point to a batch file that does something like:

start /wait my_editor %*

(but this is just a guess and I'm not in a situation to test it right now).

like image 107
Greg Hewgill Avatar answered Sep 19 '22 00:09

Greg Hewgill


I use Atom - and was getting the same problem.

git config --global core.editor "atom --wait"

... fixed it for me straight away.

More info about setting up different code editors can be found here: https://help.github.com/articles/associating-text-editors-with-git/

like image 44
Matt Avatar answered Sep 21 '22 00:09

Matt