How to reorder last two commits in git?

前端 未结 4 1082
你的背包
你的背包 2021-02-02 07:09

I want to reorder last two commits in git:

right now I have:

$ git log --oneline -4
1e0ecba (HEAD, my-branch) Fix for T255
82d45dc django_extensions
af3953         


        
4条回答
  •  醉梦人生
    2021-02-02 07:12

    I truly recommend to read this answer about how to reorder commits, you'll feel like a git rockstar afterwards, I promise.


    Apart from that, here's how you do it with a simple rebase (assuming you're standing on the branch you want to rebase):

    git rebase -i HEAD~2

    Next, change the order of the commits in the prompt.

    pick f4648aee My first commit
    pick 00adf09a My second commit
    

    to

    pick 00adf09a My second commit
    pick f4648aee My first commit
    

    Unbelievable that it can be that simple, if you ask me.

提交回复
热议问题