"git rebase -interactive" is silently written trying to reorder them

I noticed that I silently lost commits on startup git rebase --interactive

and so I recreated the problem in a simple repo for testing.

I have four commits and I would like to reorder two of them. This is where my startup finishes:

55d4ca6 1  <-- origin/master  
d70d325 2  
b613c5b 3  
2bd1177 4  <-- master

      

Each commit is independent of the others; they all manipulate different files. I would like to reorder commits to switch to commits 2 and 3. I'm going to do this with git rebase --interactive origin/master

. Running this command gives me my commits on the vim window in this order as expected:

pick d70d325 2  
pick b613c5b 3  
pick 2bd1177 4

      

I'm going to swap 2 and 3, so I reorder them in vim like so:

pick b613c5b 3  
pick d70d325 2  
pick 2bd1177 4

      

I expect both commits to change, for example:

55d4ca6 1
bf330a8 3  
5c6f9af 2  
7cb8db1 4

      

In practice, however, one of my commits just disappeared and my repo was left with this:

55d4ca6 1  
7de7fb0 3  
10fc3a7 4

      

Am I using it rebase --interactive

wrong? Or is this a bug in Git?

I am on the latest Window Git (1.9.5.msysgit.0). I've noticed this intermittently over the past few months, across multiple versions of Git.

Edit 1: Replace vim and gitk images with text. Check out the original question if you want to see exactly what I'm seeing.

+3


source to share


1 answer


Because of the shortcut, I was actually executing the command git rebase --interactive --preserve-merges origin/master

. Using these commands together and attempting to reorder commits are listed in the BUGS git section of the reordering documentation .

There is a problem in the BUGS section that is exactly equivalent to what I was trying to describe above, and probably explains better what is going on.



Answer: When you try to reorder on use, rebase --interactive --preserve-merges

you will discard commits. Don't use them together.

+5


source







All Articles