How do I reset the working tree without moving HEAD?

后端 未结 3 1554
青春惊慌失措
青春惊慌失措 2021-01-04 13:19

Given a git branch with some commits on it (C is the most recent commit):

A -> B -> C

How do I reset my workspace so that all the fil

3条回答
  •  青春惊慌失措
    2021-01-04 13:53

    Just use git checkout:

    $ git checkout HEAD~
    $ # Or
    $ git checkout HEAD^
    $ # Or
    $ git checkout B
    

    This will bring you into a detached head state where the HEAD is detached from a branch.

提交回复
热议问题