0

I'm trying to reorder 3 commits.

My current condition is:

A -> B -> C

I would like to rebase and get to this:

A -> C -> B

(just swap commits B and C)

I run the command git rebase -i A.

My editor opens up, I change the picks done and save. Nothing happens.

I notice the following:

When I run the rebase command, my editor opens but also I already see the following in the terminal:

Successfully rebased and updated refs/heads/master.
rm: cannot remove `/path/to/git/repo/.git/rebase-merge': Directory not empty

Even though I still did not do anything after running the rebase command (I did not edit anything yet in my editor).

What am I missing?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
galp
  • 3
  • 3

1 Answers1

0

It may not seem like it at first, but this is essentially a duplicate of How can I use gvim for svn commit messages under Windows? That is, this is a vim/gvim flags and/or settings issue. (This problem in general occurs with many GUI-based editors, not just gvim, but the cure for each depends on the GUI-based editor.) You are telling Git to run gvim, and Git does so in a way in which gvim delivers a "please edit this other file" request to a separate instance of itself.

Having delivered the request, the gvim that Git ran says: "All done!" It exits successfully and Git thinks this means "all done editing." Git reads the file, which of course is not done—some other instance of gvim is now running, letting you edit the directives file—and Git sees the original unchanged file and does a no-op rebase.

The cure is to instruct the gvim that Git runs to stick around, waiting until the requested file edit is completed. Then when the gvim that Git ran has exited, the file really is done, and Git can proceed to read it. I don't use this particular editor and mode so don't know whether -f as a startup flag, or the .vimrc setting (set guioptions+=f), is superior.

(Aside: the failure to remove the directory occurs because gvim has created a .swp file within it.)

torek
  • 448,244
  • 59
  • 642
  • 775