0

I observed an unexpected behavior in an interactive rebase today. It was always my understanding that if I run an interactive rebase and don't change anything in the editor, it should not have any effect, but apparently that's not so (at least on a specific repo im working with which sadly I cannot share).

Lets say we have

A -> B -> C -> D <--HEAD

and I run git rebase -i A I expect to see

pick B pick C pick D 

but in the repo I'm working on I got

pick C pick B pick D 

instead. If I close the editor and git does its thing, the result is:

A -> C' -> B' -> D' <--HEAD

Does anybody know what circumstances might lead to a behavior like that?

1
  • 2
    They should indeed be in topo order. To make sure you're seeing topo order, use git log --graph or git log --topo-order. If they're not properly sorted, that's a bug. Commented Nov 28, 2022 at 11:30

1 Answer 1

1

I suspect you inspected your history by running git log.

When your intention is to view the history of your repo (with your own human eyes, as opposed to using git log to extract data for a script), I strongly suggest to add the --graph option, otherwise you are "history blind" and do not see how commits are related to one another :

# a very handy command to view your repo's history: git log --oneline --graph # Someone once said he aliased this to 'git lol' and I stuck with it: git config --global alias.lol "log --oneline --graph" git lol git lol master origin/master git lol --all ... 

You describe something you can see if your history contains a merge commit of some sort :

* D * merged |\ | * C * | B |/ * A 
Sign up to request clarification or add additional context in comments.

1 Comment

Ah that was it. Obvious in hindsight, came in with the wrong assumptions of what had previously happened on the branch. Thanks for the info!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.