Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is "git log" newest first but "git rebase -i" oldest first?

Tags:

git

git log output shows newer entries first:

+>git log --oneline
0614cce adding d
8bcf445 adding b AND c
1fce972 adding a

Whereas if I do git rebase -i HEAD~2, the interactive editing file shows commits with oldest first:

  1 pick 8bcf445 adding b AND c
  2 pick 0614cce adding d
  3
  4 # Rebase 1fce972..0614cce onto 1fce972
  5 #
  6 # Commands:
  7 #  p, pick = use commit
  8 # etc...

What's the motivation for this decision?

like image 327
Jonah Avatar asked Oct 03 '22 15:10

Jonah


1 Answers

It shows the commit in the order it will apply them on top of a commit.

It applies those from the oldest to the newest.

You can then (with an interactive rebase) change that order, drop some commits entirely, or squash commits together.


Note: be careful if your git log is during a reword of an interactive rebase: see "git rebase -i shows wrong commit history after a rebase and force push".
Use Git 2.24+ (Q4 2019).

like image 170
VonC Avatar answered Oct 13 '22 01:10

VonC