Undoing a git pull --rebase

后端 未结 4 1058
面向向阳花
面向向阳花 2021-01-30 09:00

Hey I\'m new to git and I need to undo a pull, can anyone help?!? So what I\'ve done is...

  1. git commit
  2. git stash
  3. git pull --rebase
  4. git st
相关标签:
4条回答
  • 2021-01-30 09:08

    Use git log -g and find the commit index you want to go back to, the just do git checkout index

    0 讨论(0)
  • 2021-01-30 09:19

    Actually, to make this easier Git keeps a reference named ORIG_HEAD that points where you were before the rebase. So, it's as easy as:

    git reset --hard ORIG_HEAD
    
    0 讨论(0)
  • 2021-01-30 09:26

    You should checkout the command

    git reset --merge
    

    That eliminates the need for a git commit; git stash before a pull (Don't know about rebase though)

    The command returns a workspace with uncommitted changes to the state before a conflicting pull.

    0 讨论(0)
  • 2021-01-30 09:27

    using git reflog you will see a list of commits HEAD pointed to in the past

    using

    git checkout -b after-commit HEAD@{1} # or the commit you want to recover
    

    you create a new branch at that precise position and check it out

    0 讨论(0)
提交回复
热议问题