How to get back to most recent version in Git?

前端 未结 10 1196

I have recently moved from SVN to Git and am a bit confused about something. I needed to run the previous version of a script through a debugger, so I did git checkout <

10条回答
  •  半阙折子戏
    2021-01-29 18:06

    When you go back to a previous version,

    $ git checkout HEAD~2
    Previous HEAD position was 363a8d7... Fixed a bug #32
    

    You can see your feature log(hash) with this command even in this situation;

    $ git log master --oneline -5
    4b5f9c2 Fixed a bug #34
    9820632 Fixed a bug #33
    ...
    

    master can be replaced with another branch name.

    Then checkout it, you'll be able to get back to the feature.

    $ git checkout 4b5f9c2
    HEAD is now at 4b5f9c2... Fixed a bug #34
    

提交回复
热议问题