Home > database >  The rebase commit order confusion
The rebase commit order confusion

Time:10-02

I get this snapshot of git rebase:

enter image description here

you see the feature commits is in the front of master after rebase.

but however, I test in my repo, (origin/repo master vs local/repo master).

the commit order is local/repo master is in the front after rebase.

the result:

Time sequence of commits:

local/repo master 1111

origin/repo master 333
origin/repo master 444
origin/repo master 555

after rebase from

$ git log --oneline --graph
* a7b57ce (HEAD -> master) 1111   # this commit of local/repo master become the latest. 
* 4255c42 (origin/master, origin/HEAD) 555
* 0eafba2 444
* 4838fca 333

this violates the snapshot which display the be rebased branch commits should in front of the one who initiate the rebase.

CodePudding user response:

The direction you rebase in affects the results:

Rebase foo onto bar:

git log --oneline --graph foo bar

* 7b56f8f (HEAD -> bar) 33
| * 4ac5cb6 (foo) 22
|/  
* 0d5ab43 11

git checkout foo
git rebase bar
git log --oneline --graph foo bar

* 35c0b9e (HEAD -> foo) 22
* 7b56f8f (bar) 33
* 0d5ab43 11

Rebase bar onto foo:

git log --oneline --graph foo bar

* 7b56f8f (HEAD -> bar) 33
| * 4ac5cb6 (foo) 22
|/  
* 0d5ab43 11

git checkout bar
git rebase foo
git log --oneline --graph foo bar

* affebfd (HEAD -> bar) 33
* 4ac5cb6 (foo) 22
* 0d5ab43 11
  •  Tags:  
  • git
  • Related