开发者

Undo git pull origin main? [duplicate]

This question already has answers here: Undo git pull, how to bring repos to old state (15 answers) Closed 10 hours ago. 开发者_JS百科

is it possible to undo a git pull origin main? I did it accidentally on a branch I did not wanted to download changes, is there a command to undo it or restore this repository to what it was before doing the pull?


Here are some options:

  1. Ultimately you'll do a pull anyway so you could just continue work from where you are.
  2. Scan the history of the branch you want to rewind and find the last commit you want and rewind the branch to that spot:
    1. create another branch from that commit, or
    2. git reset --hard commit_id() if you're sure about what you're doing; this will "remove" all the commits and make the branch's tip *commit_id`
  3. Check git reflog and you should find an entry that says pull: and you could rewind to that.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜